• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reg :UTF 8  RSS feed

 
chennai Kumar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai All,

When i execute the following program i am getting this out put.

Output : Activité?i?

code :




Characters " ź " and " ń" is not printing.
"?" is replaced for those characters.
Can you please help me to solve this.

Advance thanks,
Ram Kumar
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are you printing this - to a console of some kind? Most (all?) consoles can't handle the full range of Unicode characters.
 
Alan Moore
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that you aren't using UTF-8. You're using the system default encoding, which doesn't support those two characters. There are four parts to the problem: (1) You have to save the source file in an encoding that supports those characters. (2) You have to tell the compiler to read the source file with the same encoding. (3) When you write the output, you have to specify an appropriate encoding. (4) If you're writing to the console, you have to tell it to use the same encoding; if you write to a file, you have to make sure the editor you use to read the file uses the right encoding.

You can eliminate the first two parts of the problem by using Unicode escapes for any non-ASCII characters: As for the other two parts, the easiest solution is to avoid the console; it's too difficult to work with and too system-dependent. Just write to a file and specify the correct encoding: You can then read the result with any reasonably good editor (but try to avoid Windows Notepad).
 
chennai Kumar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks I got the output.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!