Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

unicode problem in HTMLEditorKit  RSS feed

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My program use StringWriter to get the unicode in a HTMLEditorKit by this code:
Writer textOut = new StringWriter();
htmlEditorkit.write(str, doc, start, end);
The string I got from this method is in the format of decimal unicode (e.g. 雅). Actually, I do not mind that it is in this format. However, I need to save this string into a file with the format of UTF-8. I have tried to use the following codes:
FileOutputStream fos = new FileOutputStream(new File(fileName));
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
out.write(str);
...
However, the content in the file saved is still in the format of decimal unicode.
How can I get the file with the content in the UTF-8? Thanks!
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!