Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Welsh characters in Property entry
Welsh characters in Property entry [message #299739] Thu, 23 February 2006 10:11 Go to next message
Eclipse UserFriend
Originally posted by: luca.baldi.idoxplc.com

Hi.
I am developing my own plugin, and I am using a property sheet to view
the properties. For the properties which have a TextPropertyDescriptor,
I would like to be able to display Welsh characters ( or any UTF-8
character ). I can copy/paste my text, and the Welsh characters are
displayed correctly. The problem is that after I save the changes ( I
save the data model as a .xml file ) and restart my plugin, the Welsh
character is displayed as "Ŷ" ( strange sequence of characters ).
What's confusing me is that if I open my .xml file using Firefox, the
Welsh character is displayed correctly, while if I use IE the same
strange sequence is shown.

The first line of the saved .xml file is the following

<?xml version="1.0" encoding="UTF-8" ?>

When I serialise my Java beans, I specifically state the encoding
character set as UTF-8. Here's the code snippet

public void write(Object bean, OutputStream os, String encoding) {
PrintWriter writer = new PrintWriter(new
OutputStreamWriter(os, Charset.forName(encoding)));
writer.print("<?xml version=\"1.0\" encoding=\"");
writer.print(encoding);
writer.println("\" ?>");
xstream.toXML(bean, writer);
}

Any suggestion would be greatly appreciated.
Thanks

Luca
Re: Welsh characters in Property entry [message #299749 is a reply to message #299739] Thu, 23 February 2006 11:32 Go to previous messageGo to next message
Eclipse UserFriend
Do you do the same with the parser

SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
ParserAdapter pa = new ParserAdapter(sp.getParser());
pa.setContentHandler(this);
fis = new FileInputStream(file);
pa.parse(new InputSource(new InputStreamReader(fis, UTF_8)));
Re: Welsh characters in Property entry [message #299751 is a reply to message #299749] Thu, 23 February 2006 12:56 Go to previous message
Eclipse UserFriend
Originally posted by: luca.baldi.idoxplc.com

Phill_Perryman@Mitel.COM wrote:
> Do you do the same with the parser
>
> SAXParserFactory spf = SAXParserFactory.newInstance();
> SAXParser sp = spf.newSAXParser();
> ParserAdapter pa = new ParserAdapter(sp.getParser());
> pa.setContentHandler(this);
> fis = new FileInputStream(file);
> pa.parse(new InputSource(new InputStreamReader(fis, UTF_8)));

Hi there.
Too right, I was encoding when writing out to the stream, but not taking
that into account when reading stuff back in using xstream.
I am now using a com.sun.syndication.io.XmlReader which I pass to
sxtream when reading the saved file and it works fine.
Thanks

Luca
Previous Topic:Adding a view to a multipage editor
Next Topic:creating icons defined in a different plugin
Goto Forum:
  


Current Time: Tue Jul 15 04:03:28 EDT 2025

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

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

Back to the top