jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • XStream
  • XSTR-131

DomDriver UTF-8 not working

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Resolution: Won't Fix
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

I am using XStream 1.0.2. The following two codes produce the same output:

--------------- Sample 1 --------------
final XStream x1 = new XStream(new DomDriver("UTF-8"));
x1.toXML(teststring, new FileWriter("test-encoding-1.xml"));

--------------- Sample 2 --------------
final XStream x2 = new XStream(new DomDriver());
x2.toXML(teststring, new FileWriter("test-encoding-2.xml"));

--------------- End Samples -----------

Given the teststring variable is "Ää Öö Üu", the output for both is identical:

00000000h: 3C 73 74 72 69 6E 67 3E ; <string>
00000008h: C4 E4 20 D6 F6 20 DC FC ; Ää Öö Üü
00000010h: 3C 2F 73 74 72 69 6E 67 ; </string
00000018h: 3E ; >

Obviously, the umlaut encoding does not take place in UTF-8, which (to my expectations) would look like this:

00000000h: 3C 73 74 72 69 6E 67 3E ; <string>
00000008h: C3 84 C3 A4 20 C3 96 C3 ; Ää Ã-Ã
00000010h: B6 20 C3 9C C3 BC 3C 2F ; ¶ Üü</
00000018h: 73 74 72 69 6E 67 3E ; string>

The encoding of the above code snippets rather take place in my Windows XPs default encoding schema ISO-8859-1.

Issue Links

is superceded by

Bug - A problem which impairs or prevents the functions of the product. XSTR-261 Xstream.fromXML(InputStream) should discover the stream encoding, impossible to specify output encoding

  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • History
  • Activity
Hide
Permalink
Matthias Wessendorf added a comment - 13/Jun/05 9:04 AM

I noticed the same behaivor and I am using xstream 1.1.2

Are there any updates on this issue ?

Regards,
Matthias

Show
Matthias Wessendorf added a comment - 13/Jun/05 9:04 AM I noticed the same behaivor and I am using xstream 1.1.2 Are there any updates on this issue ? Regards, Matthias
Hide
Permalink
Matthias Wessendorf added a comment - 14/Jun/05 2:42 AM

Daniel, I fixed my issue by telling the reader (and writer also) to use UTF-8

<snip>
InputStream is = null;
InputStreamReader reader = null;
try { is = new BufferedInputStream(new FileInputStream(pathname)); reader = new InputStreamReader(is, "UTF-8"); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (UnsupportedEncodingException uee) { uee.printStackTrace(); }

xstream.fromXML(reader);

</snip>

HTH,
Matthias

Show
Matthias Wessendorf added a comment - 14/Jun/05 2:42 AM Daniel, I fixed my issue by telling the reader (and writer also) to use UTF-8 <snip> InputStream is = null; InputStreamReader reader = null; try { is = new BufferedInputStream(new FileInputStream(pathname)); reader = new InputStreamReader(is, "UTF-8"); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (UnsupportedEncodingException uee) { uee.printStackTrace(); } xstream.fromXML(reader); </snip> HTH, Matthias
Hide
Permalink
Joerg Schaible added a comment - 09/Nov/06 4:30 PM

As Matthias has pointed out, a JDK Writer will use a different encoding by default, but it should match the one of the driver. Write into a ByteArrayOutputStream to prevent further encoding.

Show
Joerg Schaible added a comment - 09/Nov/06 4:30 PM As Matthias has pointed out, a JDK Writer will use a different encoding by default, but it should match the one of the driver. Write into a ByteArrayOutputStream to prevent further encoding.

People

  • Assignee:
    Unassigned
    Reporter:
    Daniel Frey
Vote (0)
Watch (0)

Dates

  • Created:
    25/Sep/04 8:20 AM
    Updated:
    09/Nov/06 4:32 PM
    Resolved:
    09/Nov/06 4:30 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.