• 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

encoding in java

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

i recently made some changes to my encoding of soap xml file. below is my encoding code: filename is a string that contains the name of a file.... content is a string that contains the soap message.



however, i am getting a few undesirable characters at the beginning of my soap file 

eg.




because of those characters, i am having problem with sending the soap xml to the server.

can someone please help me to do a proper utf-8 encoding ? did i do it wrongly?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

however, i am getting a few undesirable characters at the beginning of my soap file


What is the content of out.write(content); ? Did you debug it ?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That looks like a byte-order mark (see also this), which are special bytes to let whatever program that reads the file know if the Unicode characters are stored in little endian or big endian order.

In principle, this should not be a problem, but some software does not properly recognise the BOM and reports an error.

Sorry, I don't know how to prevent the BOM from being generated, but maybe you can find a solution yourself by Googling around about Java, Unicode and BOMs.
 
bryan lim
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for your reply.

the content is [quote<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <Authentication xmlns="http://www.maildirect.se/30/WebServices/"> <UserName>check@gmail.com</UserName> <Password>passwprd</Password> </Authentication> </soap:Header><soap:Body><CreateList xmlns="http://www.maildirect.se/30/WebServices/"><name>_2009_3_31</name><description>_2009_3_31</description></CreateList></soap:Body></soap:Envelope> which i mentioned above....

the first few undesirable characters are 


thank you
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So where is "content" coming from? Java I/O doesn't add the BOM by itself - there must be code somewhere that adds that.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Too difficult a question for us beginners.
Moving.
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Locked duplicate thread on this, continuing here.
 
reply
    Bookmark Topic Watch Topic
  • New Topic