Jump to content
  • Advertisement
Sign in to follow this  
HellCreator

Urgent utf-8 to ascii

This topic is 4900 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Please I need help with bitmaped fonts as in nehe tutorials there 3 bmp files with russian,hebrew and arabic fonts with range 0-255 16*16 pixels each gliph they loaded and stored in diferent gltexid[3] I reading string from file utf-8 coded only one language is used in one single file.I need to convert it some how to ascii lower for latins and to uppers respectively for other languages then i will pass it to glprintf(fontif,str)

Share this post


Link to post
Share on other sites
Advertisement
I think you can use MultiByteToWideChar to convert the UTF-8 string to 16-bit unicode and then WideCharToMultiByte to convert it back to the desired character set (code page).
You still need to choose which character set to use somehow. One way would be to try to convert the string into each available font, count the number of unrepresentable characters and select the best match.

Another possibility would be to create your own unicode mapping table for all of the fonts. This could be accomplished by calling MultiByteToWideChar to translate each character in each font into unicode and storing them in a common table indicating which font and character index to use.
But then you'd have to handle 16-bit characters further into the system which might complicate things.

Share this post


Link to post
Share on other sites
Quote:
Original post by Intamin AG
tolower ?? toupper?? see MSDN... its part of the STL i just dunno if it works with UTF-8

Thanks
MSDN not relevant anymore to me I using java the question is more general
my code work only hardcoded but in different way on diferent OS respectively to CP or locale installed

String text1="english text";
String text_he="òáøéú text";
byte[]ru={178,200,193};
String line=fromfile.getBytes("UTF-8");
...do raster here
gl.glprintf2d(10,10,0,text1);//english string hardcoded
gl.glprintf2d(10,28,0,text_he);//hebrew hardcoded to Latin1
gl.glprintf2d(10,44,0,ru);//ascii hardcoded each byte
gl.glprintf2d(10,62,0,line);//all goes wrong here !!!!
...back to original projection type


when I compile it then working fine - it compiled into Latin1 set
but if I pass string from file or from console then output unexpected
String is multibyte each char is 2 bytes
and when I pass it to glprintf the function processes each byte in array such as
gl.glCallList(gl_list_array[text[curent_byte]]); and if I make my array byte by byte handly it works allways because I know ascii of each ext page for my languages

Share this post


Link to post
Share on other sites
Quote:
Original post by doynax
Another possibility would be to create your own unicode mapping table for all of the fonts...


Thanks it was urgent thread but today I did my presentation
and has choosed not to show russian and arabic sets

Finally I got 96 score on my college degree project

Actually I was thinking about this option too
but it makes to die of rapid programming consept in java?
When no choise I will do it exact that way You proposing
With respect to Your idea but I will be in need to provide to my IDE also some converter to my "/uX" format

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!