Skip to content

Commit

Permalink
Merge pull request #32 from xjchengo/multibyte-string-supported-replace
Browse files Browse the repository at this point in the history
[Bug Fix]使用支持多字节的字符串替换函数
  • Loading branch information
overtrue committed Jan 19, 2016
2 parents 17cd2c7 + 3477259 commit bd66831
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Pinyin/Pinyin.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,18 @@ protected function prepare($string)
* Add delimiter.
*
* @param string $string
* @param string $delimiter
*
* @return string
*/
protected function delimit($string, $delimiter = '')
{
return preg_replace('/\s+/', strval($delimiter), trim($string));
$defaultEncoding = mb_regex_encoding();
mb_regex_encoding(static::$internalCharset);
$string = mb_ereg_replace('\s+', strval($delimiter), trim($string));
mb_regex_encoding($defaultEncoding);

return $string;
}

/**
Expand Down

0 comments on commit bd66831

Please sign in to comment.