cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Anyone tackled PE and UTF-8?

JosephM.Fedel
1-Newbie

Anyone tackled PE and UTF-8?

I'm sending UTF8 encoded strings across http to the PE server but they're getting mangled into unusable strings.

For example:

<!-- 中,您将学如何使用 -->

becomes a garbled string, either:

<!-- 中 xEFxBC?XE6?XA8XE5XB0学习xE5xA6xBD?Xa* -->

or

<!-- ????????????? -->

depending on how I write to code on the server.

The internet/Java sites suggest a variety of fixes, none are working.

Some suggest adding enctyle or <meta> to my html form:

<form method="POST" action="http://132.253.204.201:8080/e3/servlet/e3" enctype="application/x-www-form-urlencoded; charset=utf-8">

<meta http-equiv="Content-type" content="text/html; charset=utf-8" />

These don't help.

Some suggest different combinations of ways to read the object at the server, like:

new FileOutputStream("D:\\UTF8Output_2.txt"), "UTF-8");

or

BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(request_XML_filename),"UTF8"));

or

BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(request_XML_filename),"UTF-8"));

None of these work.

Has anyone tacked this yet?

1 ACCEPTED SOLUTION

Accepted Solutions

Found the right combination:

Read the E3ApplicationRequest object with:

final String req_XML_string_2 = new String(req.getParameter("p2").getBytes("iso-8859-1"), "UTF-8");

and write the file with:

Writer writer_2 = new OutputStreamWriter(new FileOutputStream("D:\\UTF8Output_2.txt"), "UTF-8");

BufferedWriter fout_2 = new BufferedWriter(writer_2);

fout_2.write(req_XML_string_2);

fout_2.close();

View solution in original post

1 REPLY 1

Found the right combination:

Read the E3ApplicationRequest object with:

final String req_XML_string_2 = new String(req.getParameter("p2").getBytes("iso-8859-1"), "UTF-8");

and write the file with:

Writer writer_2 = new OutputStreamWriter(new FileOutputStream("D:\\UTF8Output_2.txt"), "UTF-8");

BufferedWriter fout_2 = new BufferedWriter(writer_2);

fout_2.write(req_XML_string_2);

fout_2.close();

Announcements