• 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

Problem writing Emdash to txt file on Solaris OS 5.9

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

I m writing a simple program as below to write EMdash(\u2014) to a file.

FileOutputStream fout =null;
try {
fout = new FileOutputStream("c:\\try.txt");
fout.write("\u2014 Em dash".getBytes());
}
catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
fout.close();
}
catch (IOException ex) {
}
}

On windows it is working fine giving proper output file(� Em dash). But on Solaris OS 5.9, It is giving (? Em dash). It is working fine for characters upto the range \u255.

Please let me know where I'm wrong.

Thanks
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This looks like on the Solaris you mention the default character encoding, as is used by String.getBytes(), can not encode the emdash. Consequently the character ends up as a question mark.

Try String.getBytes(String charsetName) and use "UTF-8" encoding.

Harald.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic