logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git

zalgo (720B)


  1. #!/usr/bin/perl
  2. # Copyright 2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
  4. use strict;
  5. use warnings;
  6. no warnings 'utf8'; # Wide Character warning
  7. my $level = 10;
  8. if($#ARGV == 0) {
  9. $level = int($ARGV[0]) or die;
  10. }
  11. my $file = '/usr/share/unicode-data/UnicodeData.txt';
  12. open my $fh , '<:encoding(UTF-8)', $file or die;
  13. my @combinings = ();
  14. while(my $line = <$fh>) {
  15. if($line =~ /;COMBINING/) {
  16. my @fields = split ";", $line;
  17. push(@combinings, hex($fields[0]));
  18. }
  19. }
  20. close $fh;
  21. my @input;
  22. {
  23. undef $/;
  24. @input = split "", <STDIN>;
  25. }
  26. foreach(@input) {
  27. print $_;
  28. foreach(1..$level) {
  29. print pack("U", $combinings[rand @combinings]);
  30. }
  31. }