Dear All,
This is small problem i am facing while writting a some extended ascii characters( range between 128 -160 vendor dependent representation of characters) on socket.
When i write them as
HEX 80 the other side program which is in C++ and on unix m/c read it as
HEX 3F
The unix side program is in C++. Conversion is like this
128 Dec 80 Hex 10000000
63 Dec 3F Hex 00111111
below code I am using..
String Data =new String ((char)128);
InetSocketAddress sockAddr =
new InetSocketAddress("1.1.1.1",50071);
Socket socket = new Socket();
socket.connect(sockAddr,100000);
BufferedReader rd1 =
new BufferedReader(new InputStreamReader(socket.getInputStream()));
String[] codePages =
{"CP437", "CP737", "CP775", "CP850",
"CP852", "CP855", "CP857", "CP860",
"CP861", "CP862", "CP863", "CP864",
"CP865", "CP866", "CP869", "CP874",
"CP856","CP858","CP868","CP870"};
BufferedWriter wr1 =
new BufferedWriter(new OutputStreamWriter
(socket.getOutputStream(),codepage[0]));
wr1.write(data);
wr1.flush();
As I searched java is always Big Endian and other side program might be Little Endian ByteOrder may be different.So this might be the reason .
Or the issue is related to character set issue i.e code pages supported by platform.
But i tried with all above character sets and its still not giving proper result..
Does Java NIO will solve the problem but never worked with it ??
Does Stream or Writer classes has to do something with it...???
Thanx ....All...
.. Sachin ..