问题
I've a text content in "xyz" language.
<p style="font-family:xyz;"> eWvS³: kmwkMnsâ kq¸Àt^mWmb KmeIvkn kocoknsâ aq¶mw]Xn¸v </p>
// It will not display correctly as font is not embedded.
here the font xyz (xyz.ttf) is non unicode.
Now I want to convert that "XYZ" (xyz.ttf) font text to unicode "PQR" (pqr.ttf) font
Simply, a non-unicode Chinese (non_uni_chinese.ttf) to uniocode Chinese (uni_chinese.ttf)
how can I make it possible using php. any help?
回答1:
You must do this "character by character".
It's mean you must replace every character in "non-Unicode Chinese" font to Unicode font. I don't know much about Chinese, but in Vietnam, they use this way:
- Write a string that contains "non-Unicode" font by an Unicode font, and these characters will not display correctly. For example: Ñaây laø Tieáng Vieät <- this is a non-Unicode Vietnamese write with an Unicode font.
- Replace "character by character". For example: Ñ = Đ; aâ = â; aø = 2;...
- Then we have this result: Đây là Tiếng Việt.
Of course we don't do it step-by-step, we use a software called "Unikey" to do this.
And I'm sure that there is a software to do that in Chinese. The point here is you must "do" it again in PHP.
Here come something can help you: http://www.pinyin.info/tools/converter/chars2uninumbers.html
Good luck.
回答2:
Generated output should use one encoding. It's not proper solution, but anyway, for converting string to different encoding you should use iconv function http://www.php.net/manual/en/function.iconv.php
来源:https://stackoverflow.com/questions/10773863/converting-non-unicode-non-english-content-to-unicode