JAXB and Arabic encoding

Brahim Machkour

Usenet Archive
Joined
Jul 25, 2003
Messages
1
Reaction score
0
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.
 

Roedy Green

Usenet Archive
Joined
Dec 17, 2000
Messages
18,395
Reaction score
0
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.
 

Mark Thornton

Usenet Archive
Joined
Jul 18, 2003
Messages
562
Reaction score
0
Brahim said:
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 :

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

Usenet Archive
Joined
Jul 18, 2003
Messages
562
Reaction score
0
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.

Completely untrue. With the exception of the special characters which must be escaped (< &) you can use any character which your chosen encoding supports directly. Only characters not supported by your encoding must be represented by a character reference. Of course you can also use a character reference for characters which are direcly representable.

Prior to Java 1.4 it was difficult to write a transcoder (in Java) which would use character references only when strictly necessary. (A 'transcoder' is an application which translates an XML document from one encoding to another without changing the meaning.)

Mark Thornton
 

Jon A. Cruz

Usenet Archive
Joined
Jan 16, 2000
Messages
261
Reaction score
0
Roedy said:
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.
 

Jezuch

Usenet Archive
Joined
Jul 2, 2003
Messages
46
Reaction score
0
U�ytkownik Jon A. Cruz napisa�:
Just Use UTF-8 on the XML file and view it in Notepad. You can even have Arabic identifiers.

Just like you can have Unicode identifiers in Java.
See http://www.javaspecialists.co.za/archive/Issue036.html
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,802
Members
249,594
Latest member
henrywalsh

Latest Threads

Top