ICE client encoding GBK error

in Help Center
I use ice java client to get chinese string from Ice c++ server,but it show "?"all.
Ice Server:
Linux 2.4.30 + gcc 3.3.4 + Ice-3.0 + ISO-8859-1
Ice Client:
Windows 2000 + Jdk 1.5 + IceJ-2.1.2 + GBK
I solved this problem by calling iconv in c ;
this function help me transfer gbk to utf8 , then java receive the string in right coding format.
But my question is:
if I do not transfer gbk to utf8 in c, how can java receive the string in right coding format?
May you provide some advice . Thank u so much!!
Ice Server:
Linux 2.4.30 + gcc 3.3.4 + Ice-3.0 + ISO-8859-1
Ice Client:
Windows 2000 + Jdk 1.5 + IceJ-2.1.2 + GBK
I solved this problem by calling iconv in c ;
this function help me transfer gbk to utf8 , then java receive the string in right coding format.
But my question is:
if I do not transfer gbk to utf8 in c, how can java receive the string in right coding format?
May you provide some advice . Thank u so much!!
0
Comments
Strings should always be encoded with UTF-8 on the wire. So your application should provide UTF-8 strings to the Ice runtime and should expect receiving UTF-8 strings from servers. However, with Ice for C++, you can install with the Ice communicator an automatic converter to automatically convert your strings to and from UTF-8.
See the demo/Ice/converter demo from your Ice distribution for an example and the section "30.21 C++ String Conversion" for more information.
Cheers,
Benoit.
hi Benoit. Thank u for your advice
I have try to provide UTF-8 strings,and java can receive the string in right coding format.
But my question is:
For several reason I do not want to change my c source (it provide GBK strings , it do not transfer gbk to utf8 in c),
how can java receive the string in right coding format?
I guess if I could modify the ice.jar source(BasicStream.class) to let java receive the string wIth GBK? or any other way?
May you provide some advice for my question ?
Thanks a lot
Cheers,
Koko.
You can continue using GBK in your source if you install a converter with the Ice communicator, this is really the easiest and best solution. Or can't you even modify the source where the communicator is initialized (that's where you should setup the string converter)?
You can modify the Ice source since we provide it but I don't recommend you to do it, we won't support such a configuration.
Cheers,
Benoit.
You mean I should change my source in server?
in my project ,client must receive the string in GBK.
Except the java client,other clients should use the string in GBK.
How can I make change in the java client to let work right.
You could certainly hack your Ice for Java client so that it converts GBK to UTF-8, but we do not provide any support for this. As Benoit says, the correct solution is to convert GBK to UTF-8 at your C++ server, using an appropriate implementation of our string converter.
Thanks guys.
Cheers,
Bernard
I see.
Cheers,
Koko
infact, use stringconvert, you can resolve this problem gracefully.:D