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

utf-8 encoding

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
refer this example
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

refer this example


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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
so do you mean that the file is already in utf-8 format?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
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:
  • 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?
 
    Bookmark Topic Watch Topic
  • New Topic