I have a string with Unicode and ASCII characters.
I can use utf8_decodeto convert ASCII to Unicode characters, but also converts unicode to Unicode characters. How can I filter or convert only ASCII characters to Unicode in a mixed string?
utf8_decode
For instance:
utf8_decode(& #225; rỉ); ~> á rỉ
Two things. ASCII characters are 7-bit, from 0x00 to 0x7F. Therefore, if you have a Unicode string, ASCII characters do not need to be converted, because they are the same in Unicode ...
á 0xE1, ASCII, ISO Latin 1. ( ...). , ISO Latin 1 UTF-8.
ISO Latin 1
á ASCII. ASCII
.
echo mb_convert_encoding('á rỉ', "UTF-8", "UTF-8");
you can use $string = iconv('ASCII//TRANSLIT','UTF-8', $string);
$string = iconv('ASCII//TRANSLIT','UTF-8', $string);