sub CutString { my $string = shift; my $len = shift; my $cut = 0;
while($len != 0) { if( ord(substr($string, $cut, 1) ) >= 128 ) { $cut += 2; #korean char & } else { $cut++; } $len--; last if ($len == 0); } return substr($string, 0, $cut); }
#»ç¿ë¹ý $a = "12ÆÞ34¸¶56´Ï78¾Æ"; print CutString($a,7);
|