taking the example from http://rot8000.com/info as testcase

FYI: # $chinese = "籝籱籮 籫籾籽籵籮类 籭籲籭 籲籽簪"

use strict; use warnings; use utf8; use open ":std", ":encoding(UTF-8)"; use Test::More; # rot8000 v1.005; my %rot; init_rot(); my $english = "The butler did it!"; my $chinese = "&#31837;&#31857;&#31854; &#31851;&#31870;&#31869;&#3186 +1;&#31854;&#31867; &#31853;&#31858;&#31853; &#31858;&#31869;&#31786;" +; # fix PerlMonks' Uni<code>Mess $chinese =~ s/&#(\d+);/chr($1)/ge; is( rot8000($chinese), $english, "chin2engl -> $english" ); is( rot8000($english), $chinese, "engl2chin -> $chinese" ); my $random = join "", map { chr int rand 2**16-1 } 1..30; is( rot8000(rot8000($random)), $random, "Identity" ); done_testing; sub rot8000 { my ($in) = @_; my $out; for my $char (split //,$in) { $out .= $rot{$char} // $char; } return $out; } sub init_rot{ my @toggles = reverse (0, 33,127,161,5760,5761,8192,8203,8232,8234 +,8239,8240,8287,8288,12288,12289,55296,57344); my @allowed = map chr, 0.. 2**16-1; while ( my ($stop,$start) = splice @toggles, 0, 2 ) { #say "$start-$stop"; splice @allowed, $start, $stop-$start; } my @allowed_low = splice @allowed, 0, (@allowed/2); @rot{@allowed_low} = @allowed; @rot{@allowed} = @allowed_low; }

In reply to Re: ROT8000 implementation? by Takeshi Kovacs
in thread ROT8000 implementation? by jwkrahn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.