|
Re: Encoding option ignored in class XMLProcessor [message #1203273 is a reply to message #1202752] |
Fri, 22 November 2013 15:19 |
Ed Merks Messages: 33141 Registered: July 2009 |
Senior Member |
|
|
Arastoo,
Oh, you mean this last line
return os.toString();
should really use the encoding you've specified to decode the bytes.
That looks like a bug.
In any case, it would be better to use a StringWriter and avoid any
String -> byte[] -> String encoding. You could do that direct by
calling org.eclipse.emf.ecore.xmi.util.XMLProcessor.save(Writer,
Resource, Map<?, ?>) with a StringWriter.
On 22/11/2013 3:06 PM, Arastoo Barji wrote:
> Hello,
>
> when using method saveToString(Resource, Map) of class XMLProcessor,
> encoding option can either be set by passing option
> XMLResource.OPTION_ENCODING with value "UTF-8" or by calling method
> setEncoding("UTF-8") on the passed XmlResource object. We did both but
> somehow saveToString(...) method ignores this option.
> We implemented a workaround by calling method
> save(ByteArrayOutputStream, Resource, Map) of class XMLProcessor where
> we pass an own ByteArrayOutputStream object where encoding is set to
> UTF-8 and write the content of the outputstream into a String
> afterwards. This workaround works, but does someone know why the first
> approach doesn't work correctly? We think this might be a bug of EMF
> package but maybe we just call the method in a wrong way.
>
> Thanks,
>
> Arastoo
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.03567 seconds