I have problem with returni开发者_如何学Pythonng first letter from string, when that letter is language specific character.
Reason of that situation is simple: specific character saved in string takes more than one character, and decoding takes place only on display in html with right coding.
When i try do this on php, smarty (truncate to first character), or even mysql i have only part of that letter coded in UTF (for example: � instead of real language specific character).
Is there any way to do this right?
Thanks
Use the multibyte string functions. For example here you can use mb_substr.
$first_char = mb_substr($s, 0, 1, 'UTF-8');
Here I am assuming you are using UTF-8.
精彩评论