logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: 8ea70d790c9f56c2eb579a7aeab35fd6cd9f752b
parent bc597dbdae4518615afb337847d525e39531959f
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri, 25 Jun 2021 13:40:00 +0200

bin/zalgo: New util

Diffstat:

Mbin/Makefile2++
Abin/zalgo36++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/bin/Makefile b/bin/Makefile @@ -6,6 +6,8 @@ include Makefile.config include ../Makefile.common +EXE += zalgo + BINDIR = $(PREFIX)/bin MANDIR = $(PREFIX)/share/man diff --git a/bin/zalgo b/bin/zalgo @@ -0,0 +1,36 @@ +#!/usr/bin/perl +# Copyright 2021 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> +# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only +use strict; +use warnings; +no warnings 'utf8'; # Wide Character warning + +my $level = 10; + +if($#ARGV == 0) { + $level = int($ARGV[0]) or die; +} + +my $file = '/usr/share/unicode-data/UnicodeData.txt'; +open my $fh , '<:encoding(UTF-8)', $file or die; + +my @combinings = (); + +while(my $line = <$fh>) { + if($line =~ /;COMBINING/) { + my @fields = split ";", $line; + push(@combinings, hex($fields[0])); + } +} + +close $fh; + +my @input = split "", <stdin>; + +foreach(@input) { + print $_; + + foreach(1..$level) { + print pack("U", $combinings[rand @combinings]); + } +}