FeedAdapter and HttpSyncAdapter with UTF-8

1 view
Skip to first unread message

bgoetzmann

unread,
Jul 23, 2008, 11:53:26 AM7/23/08
to Mesh4x Discussion
Hello,

Developing my application with Mesh4j, I found and I resolved two
problems in relation with UTF-8 :

1. In FeedAdapter.java and its flush method, I changed:

XMLWriter writer = new XMLWriter(new FileWriter(this.feedFile));

by

OutputStreamWriter oswriter = new OutputStreamWriter(
new FileOutputStream(this.feedFile), "UTF-8" );
XMLWriter writer = new XMLWriter(oswriter);

That permits to be sure to work with UTF-8 encoding, and it works
correctly when writing content with accented caracters.
According to JavaDoc, FileWriter "The constructors of this class
assume that the default character encoding and the default byte-buffer
size are acceptable. To specify these values yourself, construct an
OutputStreamWriter on a FileOutputStream."

2. The second problem comes from HttSyncAdapter.java.

Data POSTed should be in UTF-8 encoding ; I made this change in the
writeData method:

out.write(content);

replaced by:

out.write(new String(content.getBytes("UTF-8")));


Bertrand ;-)
http://www.odelia-technologies.com/
Reply all
Reply to author
Forward
0 new messages