i'm echoing japanese characters fine but when i try to substr and echo out part of the string it just turn to question marks ���
note: i set my header to utf-8
header('Content-Type: text/html; charset=utf-8');
and made the meta
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
$word = "せんせい";
echo $word; //works just fine
echo substr($word,-1); //now it just echoes �
//this one also failed
echo $word[0]; //echoes �
mb_substr
will work. But, remember to add the following line at the top of your script:
mb_internal_encoding("UTF-8");//Sets the internal character encoding to UTF-8, for mb_substr to work
When working with your multibyte strings, you'll need to use the multibyte string
functions, in this case mb_substr
.
Try multibyte substrings, mb_substr() info found here This function is made for characters not in the english ascii code set.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With