• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

UTF-8 format error

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a file with utf-8 chars and i did store it in UTF-8 chars. I am attaching this file as well. But when i try to read it in UTF-8, it prints out some funky chars like ? etc. I am not sure of the exact reason.

Attaching the code


line in the file is : 1073036544 1073036799 ams MX 23 CancĂșn

output:line ??1
 
Marshal
Posts: 79039
375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are you printing it on? Is it a Windows/DOS command line? That has a restricted range of characters available.
 
Ranch Hand
Posts: 47
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sonia, I was not even able to compile your code.

Try replacing below two lines for line no. 21, 22 in your code.



It worked fine for me. Just printed the exact message you are looking for.

 
himanshu.harish agrawal
Ranch Hand
Posts: 47
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lets try to do it your way ..



Don't specify any encoding scheme because by default it is UTF-8.

You can determine which encoding an InputStreamReader or OutputStreamWriter uses by invoking the getEncoding method, which you may be aware of ..

Thanks.
 
Marshal
Posts: 28134
94
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

himanshu.harish agrawal wrote:Don't specify any encoding scheme because by default it is UTF-8.


That isn't correct. Or more precisely, it might be correct in some environments, but it certainly isn't the default in Windows JVMs.

You can determine which encoding an InputStreamReader or OutputStreamWriter uses by invoking the getEncoding method, which you may be aware of ..


Yes; you could use this statement to evaluate the truth of the first statement.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic