Sunday, August 2, 2009

Can you type in another language in a C++ program?

I'm writing a C++ program that involves translating certain things to other languages. The program itself works fine, except that when it comes to languages that don't involve the same letters as English does, I have to type in the pronunciation.





Hopefully this example will show up:





The number 1 in Hebrew is אחד





But when I type that into the C++ editor, it comes out as:


ẦầẨẩẫẬậắỎỏỞ





Or when I write it into Microsoft Word and copy-and-paste it, it comes out as only ?'s.





I end up having to write "1 in Hebrew is pronounced Echad".





Is there any way to type in another language? Can I #include a language library or something? Or is it a lost cause?

Can you type in another language in a C++ program?
The character encoding is probably wrong. For Hebrew, either ISO-8859-8 or Windows-1255 are what's typically used.





To get the text to display properly in Microsoft Word, try using the font "Arial Unicode MS". Information on the font is available at http://en.wikipedia.org/wiki/Arial_Unico... .





The proper steps for viewing the font properly in your C++ editor depends on what editor you are using -- what editor are you using, anyway? -- but generally it involves going into the tools or view menu and selecting the proper character encoding.





And, um, you're going to want to have a look at this excellent article: http://www.joelonsoftware.com/articles/U...





UPDATE:


When I copied the characters into Microsoft Word, they came out fine (i.e., as they are supposed to). What version of Microsoft Word do you have installed?
Reply:The font determines how it comes out as well. Different fonts have different "special" character codes.
Reply:I guess, what you can use is just put in the unicode number for the character for example, the character A in katakana is 30A2, and use printf instead of cout to display the character. If the destination computer supports this, hopefully, it will come out correct. Otherwise, I spose, it IS problematic...


No comments:

Post a Comment