简体   繁体   中英

display font with special characters - UTF-8

i am trying to display characters 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM