Reputation: 171
I'm trying to send from c# to java(android), via tcp a string that contains hebrew characters.
However, the data that comes to java are question marks.
Here the relevant code:
C# (m_client is tcpclient class):
NetworkStream stream = client.m_client.GetStream();
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(msg);
stream.Write(bytes, 0, bytes.Length);
Java(Android):
BufferedReader input = new BufferedReader(new InputStreamReader(m_client.getInputStream(),"Windows-1255"));
char[] buffer = new char[1024];
input.read(buffer);
return new String(buffer);
I've tried all kinds of encoding in the java part (windows-1255,UTF-8,ASCII,iso-8859-8-i,iso-8859-8), but nothing seems to work
my OS is windows 7 Thank you all in advance.
Upvotes: 0
Views: 1210
Reputation: 2247
this worked for me:
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("Windows-1255")));
Upvotes: 1
Reputation: 696
On the device go to settings/language&input and make sure the language is Hebrew or how do you say Hebrew in Hebrew. This should set the device locale I don't show it listed but then again I don't know Hebrew. Part of the headers in a http request specifically Accept-Language: lain/hebrew and this Hebrew is part of utf-8 but you do have the right to left thing. This trick could be useful if you don't have a Hebrew keyboard for testing. Good luck
Upvotes: 0