• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

handling UTF-8

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I need to transport UTF-8 message transparently as follows:
1. take a UTF-8 document (say a MIME doc)
2. convert it to a stream
3. feed it to some JAVA interface
4. and spit it out to another component
The should be the same UTF-8 input doc.
What we found is that as conversion takes place and message fed to
JAVA, the message is corrupted. Probably due to some characters which are 3-byte long in UTF-8.
Thanks
Waldle
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is your "Java interface" required to do any processing at all on the data, or is it just supposed to copy the document from one location to the other? If it's the latter, the easiest thing is to avoid Readers and Writers entirely, and just use streams to do your copying:

If you need to do any processing on the contents in Java, then you'll probably find it useful to convert the streams to Strings along the way, which is where Readers and Writers come in. If the data is UTF-8 (or any encoding other than your platform's default encoding) you must be careful to specify the encoding with an InputStreamReader or OutputStreamWriter:
 
"To do good, you actually have to do something." -- Yvon Chouinard
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic