JAXB and Arabic encoding

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brahim Machkour

    JAXB and Arabic encoding

    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 :
    [color=blue]
    > Marshaller m = jc.createMarsha ller();
    > m.setProperty( Marshaller.JAXB _FORMATTED_OUTP UT, Boolean.TRUE );
    > m.setProperty( Marshaller.JAXB _ENCODING, "ISO-8859-6" );
    > m.marshal(xmlda ta, new FileOutputStrea m(xmlfile));[/color]

    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.
  • Mark Thornton

    #2
    Re: JAXB and Arabic encoding

    Brahim Machkour wrote:
    [color=blue]
    > 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 :
    >
    >[color=green]
    >>Marshaller m = jc.createMarsha ller();
    >>m.setProperty ( Marshaller.JAXB _FORMATTED_OUTP UT, Boolean.TRUE );
    >>m.setProperty ( Marshaller.JAXB _ENCODING, "ISO-8859-6" );
    >>m.marshal(xml data, new FileOutputStrea m(xmlfile));[/color]
    >
    >
    > 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.[/color]

    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

    Comment

    • Alan J. Flavell

      #3
      Re: JAXB and Arabic encoding

      On Sat, Jul 26, Roedy Green inscribed on the eternal scroll:
      [color=blue]
      > If they did, it would not be XML any more. XML is designed to make
      > handling un-American characters difficult.[/color]

      Bloody trolls.

      Comment

      • Jon A. Cruz

        #4
        Re: JAXB and Arabic encoding

        Roedy Green wrote:[color=blue]
        > On 25 Jul 2003 01:25:54 -0700, bmachkour@yahoo .com (Brahim Machkour)
        > wrote or quoted :
        >
        >[color=green]
        >>Is there a way to have arabic charaters directly showing up in
        >>the XML ?[/color]
        >
        >
        > If they did, it would not be XML any more. XML is designed to make
        > handling un-American characters difficult.[/color]


        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.

        Comment

        Working...