JAXB and Arabic encoding

Discussion in 'XML' started by Brahim Machkour, Jul 25, 2003.

  1. Hello,

    I'm using JAXB to export/import data from/to a DB through XML files.
    Everything is working well. I would like also to be able to edit
    the file using an editor, typically XMLSpy. The problem is that
    within the XML the arabic text is encoded with strings such as
    "& #1578;& #1575;& #1585"... and using the editor, arabic does not
    appear, only the sequence of ascii strings i just mentioned. I edit
    manually and replace with arabic charater, then they show up in
    XMLSpy. I guess it's an encoding problem at marshalling ?

    I've tried anything I can at the marshalling step using :

    > Marshaller m = jc.createMarshaller();
    > m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
    > m.setProperty( Marshaller.JAXB_ENCODING, "ISO-8859-6" );
    > m.marshal(xmldata, new FileOutputStream(xmlfile));


    still the same thing. tries UTF-8, CP1256, Windows-1256, ...

    Is there a way to have arabic charaters directly showing up in
    the XML ?

    Thank you for any help

    Brahim.
     
    Brahim Machkour, Jul 25, 2003
    #1
    1. Advertising

  2. Brahim Machkour wrote:

    > Hello,
    >
    > I'm using JAXB to export/import data from/to a DB through XML files.
    > Everything is working well. I would like also to be able to edit
    > the file using an editor, typically XMLSpy. The problem is that
    > within the XML the arabic text is encoded with strings such as
    > "& #1578;& #1575;& #1585"... and using the editor, arabic does not
    > appear, only the sequence of ascii strings i just mentioned. I edit
    > manually and replace with arabic charater, then they show up in
    > XMLSpy. I guess it's an encoding problem at marshalling ?
    >
    > I've tried anything I can at the marshalling step using :
    >
    >
    >>Marshaller m = jc.createMarshaller();
    >>m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
    >>m.setProperty( Marshaller.JAXB_ENCODING, "ISO-8859-6" );
    >>m.marshal(xmldata, new FileOutputStream(xmlfile));

    >
    >
    > still the same thing. tries UTF-8, CP1256, Windows-1256, ...
    >
    > Is there a way to have arabic charaters directly showing up in
    > the XML ?
    >
    > Thank you for any help
    >
    > Brahim.


    You have to use a 'transcoder' which knows what characters can be
    represented directly in the selected encoding. Many transcoders will
    take the easy way out and just put everything not in ASCII as a
    character reference. Note that prior to the addition of the Charset
    classes in 1.4 it was tedious to determine if a given character set
    supported a character.

    Mark Thornton
     
    Mark Thornton, Jul 26, 2003
    #2
    1. Advertising

  3. On Sat, Jul 26, Roedy Green inscribed on the eternal scroll:

    > If they did, it would not be XML any more. XML is designed to make
    > handling un-American characters difficult.


    Bloody trolls.
     
    Alan J. Flavell, Jul 27, 2003
    #3
  4. Brahim Machkour

    Jon A. Cruz Guest

    Roedy Green wrote:
    > On 25 Jul 2003 01:25:54 -0700, (Brahim Machkour)
    > wrote or quoted :
    >
    >
    >>Is there a way to have arabic charaters directly showing up in
    >>the XML ?

    >
    >
    > If they did, it would not be XML any more. XML is designed to make
    > handling un-American characters difficult.



    Not at all.

    The one thing an XML parser must support to claim it is an XML parser is
    Unicode.

    Just Use UTF-8 on the XML file and view it in Notepad. You can even have
    Arabic identifiers.
     
    Jon A. Cruz, Jul 27, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hari Shankar
    Replies:
    3
    Views:
    4,175
    vphriya
    Jul 31, 2006
  2. Efy.
    Replies:
    2
    Views:
    1,119
  3. Greg
    Replies:
    4
    Views:
    2,892
    Mohamed El Ashmawy
    Mar 3, 2004
  4. Brahim Machkour

    JAXB and Arabic encoding

    Brahim Machkour, Jul 25, 2003, in forum: Java
    Replies:
    3
    Views:
    616
    Jon A. Cruz
    Jul 27, 2003
  5. Madhu Alagu

    encoding - arabic(IBM 864) to UNICODE

    Madhu Alagu, Mar 18, 2007, in forum: Python
    Replies:
    2
    Views:
    667
    Peter Otten
    Mar 18, 2007
Loading...

Share This Page