Hi All,
I want to encode few characters into UTF-8 under my Java application. For example:
String s = "D��sseldorf";
System.out.println("Test 1: " + new String(s.getBytes(Charset.defaultCharset().name()), "UTF-8"));
System.out.println("Test 11 : " + URLEncoder.encode(new String(new String(s.getBytes(Charset.defaultCharset().name()), "UTF-8"))));
produces (under Windows):
Test 1 : D�sseldorf
Test 11: D%FCsseldorf
which is correct, but when i run the same program under Linux platform, the output comes different, due to a different defaults encoding.
Test 1 : D??sseldorf //wrong
Test 11 : D%3F%3Fsseldorf //wrong
the default encodign under Linux is : US-ASCII, where as under windows: windows-1252, which seems to work.
Now could anybody please tell me the solution to this problem that is the how to solve the encoding problem under the Linux environment?
thanks.