I have a Java project that connects to a C# program that prints Turkish words. Printing Turkish characters in C# using console is not causing any problems. However, the main issue is that when this C# program is called from Java, the Turkish characters are printed weirdly. What I would like to do is to get the output printed on console and reprint it using Java GUI without having any problems with Turkish characters. I really appreciate any kind of help. Many thanks in advance
Asked
Active
Viewed 911 times
1
-
I understand the problem has to do with encoding issues (transforming between bytes and chars) but could you be a little more specific in the way your Java program connects to your C# program? I think Java is sending Strings encoded differently than the expected things. – helios Jul 27 '10 at 11:58
-
By example: Java sends "Wórd" encoded in ISO-8859-1 and it's 4 bytes. If C# decodes it in UTF-8 it will decode the byte corresponding to the ó in a bad way). – helios Jul 27 '10 at 12:00
-
It is connected through a Process. And, the output is read using BufferedReader. BufferedReader stdInput = new BufferedReader(new InputStreamReader(Process.getInputStream())); – yihlamur Jul 27 '10 at 12:31
1 Answers
0
The issue is likely to be that the C# application is encoding its character data in one encoding while the Java application is decoding the data as another. Assuming Windows, it is possibly an ANSI/OEM mismatch.
You need to identify the encoding the C# application is emitting. In the Java application, read each byte and check its hex value. Check to see if the bytes are Windows-1254, OEM-857 or whatever and then decode them appropriately using a reader with the appropriate encoding.

McDowell
- 107,573
- 31
- 204
- 267