logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Sisimai::String - String related class

Author

       azumakuniyuki

Class Methods

"token(sender,recipient)"
       token() method generates a "token": an unique string generated by the envelope sender address and the
       envelope recipient address.

           my $s = 'envelope-sender@example.jp';
           my $r = 'envelope-recipient@example.org';

           print Sisimai::String->token($s, $r);    # 2d635de42a44c54b291dda00a93ac27b

   "is_8bit(ReferencetoString)"
       is_8bit() method checks the argument include any 8bit character or not.

           print Sisimai::String->is_8bit(\'cat');  # 0;
           print Sisimai::String->is_8bit(\'ねこ'); # 1;

   "sweep(String)"
       sweep() method clean the argument string up: remove trailing spaces, squeeze spaces.

           print Sisimai::String->sweep(' cat neko ');  # 'cat neko';
           print Sisimai::String->sweep(' nyaa   !!');  # 'nyaa !!';

       "aligned" method checks if each element of the 2nd argument is aligned in the 1st argument or not.

           my $v = 'Final-Recipient: rfc822; <nekochan@example.jp>';
           print Sisimai::String->aligned(\$v, ['rfc822', '<', '@', '>']);  # 1
           print Sisimai::String->aligned(\$v, [' <', '@', 'rfc822']);      # 0
           print Sisimai::String->aligned(\$v, ['example', '@', 'neko']);   # 0

   "to_plain(ReferencetoString,[LooseCheck])"
       "to_plain" method converts given string as an HTML to the plain text.

           my $v = '<html>neko</html>';
           print Sisimai::String->to_plain($v);    # neko

   "to_utf8(ReferencetoString,[Encoding])"
       "to_utf8" method converts given string to UTF-8.

           my $v = '^[$BG-^[(B';   # ISO-2022-JP
           print Sisimai::String->to_utf8($v, 'iso-2022-jp');  # 猫

Description

       "Sisimai::String" provide utilities for dealing various strings

License

       This software is distributed under The BSD 2-Clause License.

perl v5.40.1                                       2025-04-12                               Sisimai::String(3pm)

Name

       Sisimai::String - String related class

Synopsis

           use Sisimai::String;
           my $s = 'envelope-sender@example.jp';
           my $r = 'envelope-recipient@example.org';
           my $t = time();

           print Sisimai::String->token($s, $r, $t);  # 2d635de42a44c54b291dda00a93ac27b
           print Sisimai::String->is_8bit(\'猫');     # 1
           print Sisimai::String->sweep(' neko cat ');# 'neko cat'

           print Sisimai::String->to_utf8('^[$BG-^[(B', 'iso-2022-jp');  # 猫
           print Sisimai::String->to_plain('<html>neko</html>');   # neko

See Also