It's a trivial bug. I have raise it and post a patch. See:

https://issues.apache.org/jira/browse/TUSCANY-3498

Thanks
===========Raymond Feng wrote============= 

>Hi,

>It might have something to do with the default encoding of your operating 
>system. Can you try to set the file.encoding system property?
>
>For example,
>
>java -Dfile.encoding=UTF-8 ...
>
>Thanks,
>Raymond

--------------------------------------------------
From: "ext2" <[email protected]>
Sent: Monday, March 15, 2010 12:49 AM
To: <[email protected]>
Subject: Re: Tuscany SDO-Java implementation failed to save sdo(contains 
multi-byte character) to xml

> =====On 2010-3-12 Raymond Feng wrote ======
>>Hi,
>>
>>I tried your sample inside Eclipse (I had to change the file encoding to
>>UTF-8 in the "Property" pop-up dialog).
>>
>>And I can see the result as:
>><?xml version="1.0" encoding="UTF-8"?>
>><ns:root xmlns:ns="http://ns";>中文</ns:root>
>
> I tried the sample again,as exactly as you done in Eclipse. But it still
> cannot save Chinese successfully. I have tried Tuscany SDO 1.1.1 Release 
> and
> the snap-shot source from SDO 's SVN. They both have same error;
>
> So could you tell me which version sdo you are using? And could you help 
> me
> send your eclipse project ?
>
>>package test;
>>
>>import org.junit.Assert;
>>
>>import commonj.sdo.DataObject;
>>import commonj.sdo.helper.XMLDocument;
>>import commonj.sdo.helper.XMLHelper;
>>
>>public class TestChinese {
>>    public static void main(String[] args) {
>>        String s =
>>            "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns:StringE
>>xmlns:ns=\"http://test/choice\";>中文</ns:StringE>";
>>        XMLDocument doc = XMLHelper.INSTANCE.load(s);
>>        DataObject o = doc.getRootObject();
>>
>>        //here we'll load the xml success; and the assertion will passed
>>        //
>>Assert.assertTrue(((SimpleAnyTypeDataObjectImpl)o).getValue().toString().i
n
>>d
>>exOf("中文") >= 0);
>>
>>        String xml = XMLHelper.INSTANCE.save(o, "http://ns";, "root");
>>        //assertion failed, here we'll got a xml (using utf-8 encoding)
>>contains  error character code.
>>        Assert.assertTrue(xml.indexOf("中文") >= 0);
>>        System.out.println(xml);
>>
>>    }
> }
> Thanks,
> Raymond
>
> --------------------------------------------------
> From: "ext2" <[email protected]>
> Sent: Thursday, March 11, 2010 4:47 AM
> To: <[email protected]>
> Subject: Tuscany SDO-Java implementation failed to save sdo(contains
> multi-byte character) to xml
>
>> Hi
>> The tuscany sdo 's java implementation can load xml (contains
>> muti-byte code) correct. But cannot save the sdo (has Chinese character
>> value) to xml correctly;
>>
>> For example:
>> I could load a xml(utf-8 encoding specified) which contains Chinese
>> character to sdo correctly. But it will failed to save it to xml (using
>> utf-8 encoding).
>>
>> I have ensured using correct "javac -encoding " to compile the
>> source java file.
>>
>> Code sample:
>>
>> String s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns:StringE
>> xmlns:ns=\"http://test/choice\";>中文</ns:StringE>";
>> XMLDocument doc= scope.getXMLHelper().load(s);
>> DataObject o = doc.getRootObject();
>>
>> //here we'll load the xml success; and the assertion will passed
>>
>
assertTrue(((SimpleAnyTypeDataObjectImpl)o).getValue().toString().indexOf("
>> 中文") >= 0);
>>
>> String xml = scope.getXMLHelper().save(o,  uri, name);
>> //assertion failed, here we'll got a xml (using utf-8 encoding) contains
>> error character code.
>> assertTrue(xml.indexOf("中文") >= 0);
>>
>>
>>
>
>
>
> 


Reply via email to