Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Character Encoding(Saving with a give Char Encoding, and Loading it afterwards, always return me strings a��o� if latin chars are present)
icon9.gif  Character Encoding [message #1409178] Sun, 17 August 2014 09:54 Go to next message
Rui Domingues is currently offline Rui DominguesFriend
Messages: 194
Registered: October 2010
Senior Member
Hi everyone

I'm struggling for some days with char encoding problem.

No matter if I save my resource with UTF-8, or ASCII, with
options.put(XMLResource.OPTION_ENCODING, "UTF-8");


the persisted XML mirrors that reality <?xml encoding=...>

however, when I load the resource with the same options, it always give me strings like "a��o�" if they have latin characters.

Anyone can help me?

Thanks in advance
rui domingues
Re: Character Encoding [message #1409433 is a reply to message #1409178] Mon, 18 August 2014 05:12 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30372
Registered: July 2009
Senior Member
Rui,

Comments below.

On 17/08/2014 11:54 AM, Rui Domingues wrote:
> Hi everyone
>
> I'm struggling for some days with char encoding problem.
>
> No matter if I save my resource with UTF-8, or ASCII, with
> options.put(XMLResource.OPTION_ENCODING, "UTF-8");
>
> the persisted XML mirrors that reality <?xml encoding=...>
>
> however, when I load the resource with the same options, it always
> give me strings like "a��o�" if they have latin characters.
When loading, the encoding in the XML itself is used, i.e.,
XMLResource.OPTION_ENCODING is a save option. Furthermore, the
processing to convert the bytes to characters is done by SAX itself, so
if the right characters are not coming out, then the problem must be
that the right characters are not in the file itself. One way this
could happen is if you edit the file and save it with an encoding
different from what's declared in the XML header.
>
> Anyone can help me?
It's hard to saw where things have gone wrong from what you've described...
>
> Thanks in advance
> rui domingues
Re: Character Encoding [message #1412532 is a reply to message #1409433] Tue, 26 August 2014 11:47 Go to previous messageGo to next message
Rui Domingues is currently offline Rui DominguesFriend
Messages: 194
Registered: October 2010
Senior Member
Hi. Thanks for replying.

Actually, I think my problem is related to another thing.
I'm creating an Eclipse IFile from an InputStream which is created from a string containing the model.
After that I get XMIResource from this file.

Is that possible my problem is related with the fact of being creating an eclipse file first.

Thanks in advance
rui domingues

[Updated on: Tue, 26 August 2014 11:48]

Report message to a moderator

Re: Character Encoding [message #1412540 is a reply to message #1412532] Tue, 26 August 2014 12:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30372
Registered: July 2009
Senior Member
Rui,

Comments below.

On 26/08/2014 1:47 PM, Rui Domingues wrote:
> Hi. Thanks for replying.
>
> Actually, I think my problem is related to another thing.
> I'm creating an Eclipse IFile from an InputStream which is create from
> a string containing the model.
And how exactly are you doing that? Are you making sure your string ->
byte conversion is using the encoding specified in the String? EMF has
a handy utility
org.eclipse.emf.ecore.resource.URIConverter.ReadableInputStream.getEncoding(String)
for determining the encoding specified by an XML string; you should use
that to convert your string to bytes.
> After that I get XMIResource from this file.
>
> Is that possible my problem is related with the fact of being creating
> an eclipse file first.
>
> Thanks in advance
> rui domingues
Re: Character Encoding [message #1412591 is a reply to message #1412540] Tue, 26 August 2014 14:43 Go to previous message
Rui Domingues is currently offline Rui DominguesFriend
Messages: 194
Registered: October 2010
Senior Member
Thanks a lot.

That was the real issue. I've solved the problem.
Thanks again.
rui
Previous Topic:[CDO] Low performance of CDOResource.getURI()
Next Topic:ECP SWT ViewRenderer
Goto Forum:
  


Current Time: Fri Aug 23 09:09:18 GMT 2019

Powered by FUDForum. Page generated in 0.01864 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top