#返回字符串长度 【程序编程相关:Barracuda - Framewor】
【推荐阅读:基于swt,使用easymock测试驱动】 【扩展信息:基于VFW的视频应用程序开发】use string::multibyte;
$gbk_str="上大"; $gbk= string::multibyte->new(´gbk´); $gbk_len = $gbk->length($gbk_str);constructor
new(charset)">$mbcs = string::multibyte->new(charset) new(charset,_verbose)">$mbcs = string::multibyte->new(charset, verbose)charset is the charset name; exactly speaking, the file name of the definition file (without the suffix .pm). it returns the instance to tell methods in which charset the specified strings should be handled.
charset may be a hashref; this is how to define a charset without .pm file.
# see perlfaq6 :-) my $martian = string::multibyte->new({ charset => "martian", regexp => ´[a-z][a-z]|[^a-z]´, });if true value is specified as verbose, the called method (excepting islegal) will check its arguments and carps if any of them is not legally encoded.
otherwise such a check won´t be carried out (saves a bit of time, but unsafe, though you can use the islegal method if necessary).
check whether the string is legal
检测字符串是否是合法的gbk字符
islegal(list)">$mbcs->islegal(list)returns a boolean indicating whether all the strings in arguments are legally encoded in the concerned charset. returns false even if one element is illegal in list.
length
length(string)">$mbcs->length(string)returns the length in characters of the specified string.
reverse
字符串倒置
... 下一页