Closed lianglee closed 3 years ago
What encoding is the text? This library only works with Latin1 (ISO 8859-1), Windows-1252, and UTF8, as the readme says.
@garrettw the string seems utf8
var_dump(mb_detect_encoding($string)); string(5) "UTF-8"
One other observation is if i use fixUTF8 the string become with question marks but running toUTF8 on UTF8 string gives correct result. Now how to know which one should we use ? I mean how we know if string is garbled ? as its dynamic string.
Maybe try to use iconv.
With the iconv translit parameter, fixUTF8 return a string without question marks, but... some character are replaced by another :
ie č => c
or ř => r
$str = 'áíýšžčěřůúď';
$strf = Encoding::fixUTF8($str, Encoding::ICONV_TRANSLIT);
var_dump($str); //string(22) "áíýšžčěřůúď"
var_dump($strf); //string(17) "áíýšžceruúd"
Note: It's only a workaround and not a solution (due to some data loss)
thanks!
Example text:
...::fixUTF8($text)
Outputs with ? question marks for some chars example
ž
returned as question mark ?