开发者

display font with special characters - UTF-8

开发者 https://www.devze.com 2022-12-27 06:53 出处:网络
i am trying to display c开发者_开发问答haracters like £ on a device which runs under linux . it is using utf-8 charset format .

i am trying to display c开发者_开发问答haracters like £ on a device which runs under linux . it is using utf-8 charset format . when i get to display a string which contains special characters, it displays other characters too . if i print the string on the console it appears ok, but when i parse the string to load each letter font on the screen it gets weird and the output is not the correct one .

Has anyone experienced something like this or is able to give me some advice .

Thank you.


If the string is in UTF-8, you need to use call such as TTF_RenderUTF8_Solid(). Thats for True Type Fonts.

If you have your own fonts and glyphs for your fonts, then you need to convert your UTF-8 string into to UTF-16 (most commonly used) or UTF-32 (in case of i18n support) and then use it to index into the glyph table.

You can't parse individual bytes of your utf-8 string into a valid character, when the font crosses the ASCII limits.

Refer these code snippets: http://unicode.org/faq/utf_bom.html

0

精彩评论

暂无评论...
验证码 换一张
取 消