note 40609 deleted from function.substr by nlopess
| From: | nlopess@php.net | Date: | Sat, 03 Jul 2004 12:05:35 +0000 |
| Subject: | note 40609 deleted from function.substr by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72409@lists.php.net to get a copy of this message | ||
Note Submitter: for SJIS Users
----
For those who want to SJIS (Japanese Encoding), this function can be used. This function is based on
the function of Windix for UTF-8 users. This function was very helpful for me. Thank you, Windix!
<?php
function sjis_substr($str,$start) {
preg_match_all(
"/[\x81-\x9f][\x40-\xfc]|[\xe0-\xfc] [\x40-\xfc]|[\xa1-\xdf]|[\x01-\x7f]/", $str,
$ar);
if(func_num_args() >= 3) {
$end = func_get_arg(2);
return join("",array_slice($ar[0],$start,$end));
} else {
return join("",array_slice($ar[0],$start));
}
return $str;
}
?>