Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello ,

I have a Datasetconatins data in greek character set for e.g.
Πριγκηποννήσου
Κομνηνών
Komninon
Διαγόρα
Diagora
Καλλιόπης
Kalliopis
Πάροδος Νίκαιας
Parodos Nikaias

Which got converted to ??????? while saving from C# string object to unsigned char in C.

Same issue with Russian language.

Please suggest some thoughts on the same.

Thanks,
Sachin
Posted
Comments
Sergey Alexandrovich Kryukov 28-Dec-12 2:53am    
There is no differences between languages, in this respect. .NET itself uses Unicode. It never looses any text data, you do. There are many ways to screw up things, including Unicode text. You need to show some code sample manifesting your problem, if you need help.

In the meanwhile, I tell you: use only Unicode and Unicode UTFs for encoding (typically UTF-8), and nothing else. This is the key.

—SA
Sergey Alexandrovich Kryukov 28-Dec-12 3:02am    
I see. Just use a tiny bit of logic...
—SA

1 solution

I just noticed: you say that you save the text in C unsigned char. What do you want then?!

Unicode code points in the subset covering Greek and Russian require up to 16 bits per character. The Unicode subset of first 216 code points is called Base Multilingual Plane. Other code points require more then 16 bits, which is also supported by Unicode. All Unicode UTFs support full set of code points; usually it's UTF-8, UTF-16 and, rarely, UTF-32. (No, UTF-8 does not mean 8 bit per character; UTF-16 does not mean 16 bits per characters; character size is variable.) Internally, .NET represents strings as UTF-16LE.

C char is only 8 bits. No way. Do something more reasonable. Forget about your legacy 8-bit encodings, they are gone.

If you have a particular problem, feel free to ask a follow-up question.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900