Win a copy of Clojure in Action this week in the Clojure forum!
    Bookmark Topic Watch Topic
  • New Topic

utf-8 encoding

 
bryan lim
Ranch Hand
Posts: 140
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
hi all,

i want to encode my file in utf-8 format. below is my code snippet:


however, when i open my file using notepad++ ......it shows encoding of ANSI...... how can i encode sucessfully? i also tried "UTF8" .......

thanks!!
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
The string "testing" contains only characters that are identical in ASCII, ANSI and UTF-8, so the editor has no way of knowing which encoding is used.

It's also possible that the editor bases its decision of whether or not UTF-8 is used on the presence or absence of a BOM (which your code does not write).
 
Rajah Nagur
Ranch Hand
Posts: 239
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
refer this example
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator

That example is actually worse than bryan's code because it uses an incorrect encoding name ("UTF8"). It's also only a partial solution because it punts on the issue of BOMs.
 
bryan lim
Ranch Hand
Posts: 140
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
so do you mean that the file is already in utf-8 format?
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
As I said, the string "testing" is identical in both encodings, so there's no way for the editor to tell the difference, barring a BOM.

I think you should read up on what UTF-8 really means, and how it does and does not differ from ASCII/ANSI. The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) is a good introduction.
 
bryan lim
Ranch Hand
Posts: 140
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
i see. thank you and i just read it. and i tested it again with a proper soap string. it works.
 
bryan lim
Ranch Hand
Posts: 140
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
hi all,

I am still having some problem with the encoding.

my xml file has a  at the front.

after googling abit, i realised it is BOM. But my code is below and doesn't include any BOM.



can someone advise me how to get the encoding right? i just want to send this xml file as a soap message. thanks!
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
I'm a bit confused by your line:

String content ="/*supposed a soap message */;

It's not valid Java... What is the actual content you're putting into the SOAP message?

Also are you seeing the BOM before or after your transport via SOAP?
 
I agree. Here's the link: http://aspose.com/file-tools
    Bookmark Topic Watch Topic
  • New Topic