Sisimai::String - String related class
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
Sisimai::String provide utilities for dealing string
token(sender, recipient)
token() generates a token: Unique string generated by an envelope sender address and a envelope recipient address.
token()
my $s = 'envelope-sender@example.jp'; my $r = 'envelope-recipient@example.org'; print Sisimai::String->token($s, $r); # 2d635de42a44c54b291dda00a93ac27b
is_8bit(Reference to String)
is_8bit() checks the argument include any 8bit character or not.
is_8bit()
print Sisimai::String->is_8bit(\'cat'); # 0; print Sisimai::String->is_8bit(\'ねこ'); # 1;
sweep(String)
sweep() clean the argument string up: remove trailing spaces, squeeze spaces.
sweep()
print Sisimai::String->sweep(' cat neko '); # 'cat neko'; print Sisimai::String->sweep(' nyaa !!'); # 'nyaa !!';
aligned checks if each element of the 2nd argument is aligned in the 1st argument or not.
aligned
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
ipv4(String)
ipv4 return all the IPv4 address found in the given string.
ipv4
my $v = "connection refused from 192.0.2.1, DNSBL returned 127.0.0.2"; my $p = Sisimai::String->ipv4($v); # ["192.0.2.1", "127.0.0.2"]
to_plain(Reference to String, [Loose Check])
to_plain converts given string as HTML to plain text.
to_plain
my $v = '<html>neko</html>'; print Sisimai::String->to_plain($v); # neko
to_utf8(Reference to String, [Encoding])
to_utf8 converts given string to UTF-8.
to_utf8
my $v = '^[$BG-^[(B'; # ISO-2022-JP print Sisimai::String->to_utf8($v, 'iso-2022-jp'); # 猫
azumakuniyuki
Copyright (C) 2014-2016,2018,2019,2021-2023 azumakuniyuki, All rights reserved.
This software is distributed under The BSD 2-Clause License.
To install Sisimai, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sisimai
CPAN shell
perl -MCPAN -e shell install Sisimai
For more information on module installation, please visit the detailed CPAN module installation guide.