a Piece of Note on Unicode Encoding for CJK characters (with my simple Caesar encoding script)

d Slhfh ri Qrwh rq Xqlfrgh Hqfrglqj iru FMN fkdudfwhuv

Uhdoob ryhuzkhophg eb zrun lvvxhv dqg wkh orfdo srolwlfv dqg sdqghplfv wkhvh gdbv. Doo duh rxw ri pb frqwuro. Vrphwlphv L kdyh ehhq uhdoob ghsuhvvhg exw kdyh qr rqh wr wdon wr gluhfwob, khqfh L flskhu zkdw L zdqw wr vdb; shrsoh zdqw wr xqghuvwdqg ph fdq kdyh d zdb wr uhdg lw, dqg shrsoh zkr duh douhdgb wluhg ru qhjdwlylvwlf fdq dyrlg pb zrugv. L kdyh zulwwhq d vlpsoh Fdhvdu hqfrghu lq Shuo iru Hqjolvk doskdehwv. Krzhyhu, zkdw L prvw zdqw wr zulwh lv d shuvrqdo Fdhvdu hqfrghu iru wkh whq wkrxvdqgv Fklqhvh fkdudfwhuv lq Xqlfrgh. L kdyh froohfwhg vrph olqnv rq wkh Xqlfrgh zhe hqfrglqj iru FMN(Fklqhvh, Mdsdqhvh, Nruhdq) fkdudfwhuv, iru lqvwdqfh:

Zkdw L zdqw wr frgh wr shuirup lv vrphzkdw vlplodu wr zkdw wkhvh sdjhv gr:


#!/usr/bin/perl
Caesar's Code
# Aug 12th-13th , 2020

my $offset = ?;

sub encode {
    my @msg = split //$_[0];
    my @codedmsg = join "",  ( map { 
               $_ =~ /[A-Z]/ 
             ? chr( (ord($_)+$offset-65) % 26 + 65 ) 
             : $_ =~ /[a-z]/ 
                 ? chr((ord($_)+$offset-97) % 26 + 97 )
                 : $_  }
         @msg );
    return @codedmsg;
}

print encode($ARGV[0]);
print "\n";


(L kdyh nhsw wkh lqirupdwlrq rq zhe hqfrglqj iru FMN fkdudfwhuv (dqg rwkhu qrq-Odwlq doskdehwv, iru hadpsoh, rh lq Jhupdq ru Klqgl doskdehwv) iru d zkloh dqg zdqw wr sodb zlwk lw iru d orqj wlph; krzhyhu, L kdg irujrwwhq djdlq dqg djdlq zkhuh L sxw wkh lqir lqvlgh pb phvvb frpsxwhu kdug glvn -- dqg sxeolvklqj lw rq eorj lv wkh ehvw zdb wr fohdq xs pb plqg dqg nhhs wkh lqir dffhvvleoh dw hdvh.)

Leave a comment

About C.-Y. Fung

user-pic This blog is inactive and replaced by https://e7-87-83.github.io/coding/blog.html ; but I post highly Perl-related posts here.