Php 带下划线字符的Concat希伯来文字符
我试图构建一个函数,将字符串转换为带下划线的字符串。 它适用于英语字符串,但不适用于希伯来语字符串 这就是功能:Php 带下划线字符的Concat希伯来文字符,php,unicode,Php,Unicode,我试图构建一个函数,将字符串转换为带下划线的字符串。 它适用于英语字符串,但不适用于希伯来语字符串 这就是功能: function underline($str){ $tmp_word = ''; foreach(str_split($str) as $char){ $tmp_word.= $char.'̲'; } return $tmp_word; } function mb_str_split( $string ) {
function underline($str){
$tmp_word = '';
foreach(str_split($str) as $char){
$tmp_word.= $char.'̲';
}
return $tmp_word;
}
function mb_str_split( $string ) {
return preg_split('/(?<!^)(?!$)/u', $string);
}
在某些情况下:
echo underline('abcd') . "<br>";
$hebrew_word = 'אבגד';
echo underline($hebrew_word) . "<br>";
echo underline( hebrev(iconv("UTF-8", "ISO-8859-8", $hebrew_word))). "<br>";
echo underline(iconv("ISO-8859-8", "UTF-8", hebrev(iconv("UTF-8", "ISO-8859-8", $hebrew_word)))). "<br>";
有解决办法吗?这与希伯来语无关,与多字节安全性不高有关 尝试使用此功能:
function underline($str){
$tmp_word = '';
foreach(str_split($str) as $char){
$tmp_word.= $char.'̲';
}
return $tmp_word;
}
function mb_str_split( $string ) {
return preg_split('/(?<!^)(?!$)/u', $string);
}
函数mb_str_split($string){
返回preg_split('/(?我建议首先使用UTF-8编码,因为它解决了大多数编码问题。检查以mb_3;开头的函数。并检查函数php字符串函数不支持unicode。str_split将丢弃希伯来字符。这就是为什么有mb_3;*()
函数支持多字节的原因。