• 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

DOMBuilder Æ Ø Å encoding issues

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.

I am getting a blob stream from database. The blob stream includes speciel characters like æ ø å and the characters are shown fine in the database.

When I try to build the Jdom document the Æ Ø Å are shown as "?".

Any help is appreciated.

 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Why are you using ISO-8859-1? Better use UTF-8.

What encoding is the database? The xml encoding should match.


 
Jeppe Summer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The XML file in database use ISO-8859-1:
<?xml version="1.0" encoding="ISO-8859-1"?>


I can try change both the XML encoding and the XMLOutputter encoding to UTF-8.
 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[1] First, you've the input in the kind of (generically binary - blob, which you know from the way it is generated be in fact sort of character steam in disguise) stream in place. Hence, I would say you should not take the detour through jaxp dom api's... you can feed directly to jdom2 via its SAXBuilder (see below). (Furthermore, I think you should use jdom2 rather than jdom, no reason to still using the latter, that the fully qualified name seems to suggest). Besides being more concise, with one level of complication taken out, it would even be easier to debug.

[2] Then when you feed the stream to the builder, you use a Reader to take into consideration of the fact that it is in fact a character stream... With a reader, you can feed the supplementary info you retain concerning the character encoding... If things match up, the behaviour of the output would be more comprehensible.

[2.1] As a side note, you should be careful not to be misled by System.out to the console because that part of the display is further influenced by the system encoding... If you can log or save to a file or display through something swing can offer (such as JTextPanel...), conclusions drawn may be more solid.

Hence, try something in sketch like this.
 
reply
    Bookmark Topic Watch Topic
  • New Topic