Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 12-20-2006
tangxiaoshu tangxiaoshu is offline
Registered User
 
Name: tang xiaoshu
Organization: snda
Project: ice java client
 
Join Date: Dec 2006
Posts: 5
Smile ICE client encoding GBK error

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!!
Reply With Quote
  #2 (permalink)  
Old 12-20-2006
benoit's Avatar
benoit benoit is offline
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,564
Hi,

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.
Reply With Quote
  #3 (permalink)  
Old 12-20-2006
tangxiaoshu tangxiaoshu is offline
Registered User
 
Name: tang xiaoshu
Organization: snda
Project: ice java client
 
Join Date: Dec 2006
Posts: 5
my question is that...

Quote:
Originally Posted by benoit View Post
Hi,

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.
Reply With Quote
  #4 (permalink)  
Old 12-20-2006
benoit's Avatar
benoit benoit is offline
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,564
Quote:
Originally Posted by tangxiaoshu View Post
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),
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)?

Quote:
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 ?
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.
Reply With Quote
  #5 (permalink)  
Old 12-20-2006
tangxiaoshu tangxiaoshu is offline
Registered User
 
Name: tang xiaoshu
Organization: snda
Project: ice java client
 
Join Date: Dec 2006
Posts: 5
How can I make change in the java client to let work right.

Quote:
Originally Posted by benoit View Post
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 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.
Reply With Quote
  #6 (permalink)  
Old 12-20-2006
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,781
Ice requires that all strings are transmitted as UTF-8. If you don't do that, then you will run into problems with other language mappings as well, such as Ice for Python.

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.
Reply With Quote
  #7 (permalink)  
Old 12-20-2006
tangxiaoshu tangxiaoshu is offline
Registered User
 
Name: tang xiaoshu
Organization: snda
Project: ice java client
 
Join Date: Dec 2006
Posts: 5
i got it

Thanks guys.
Reply With Quote
  #8 (permalink)  
Old 12-20-2006
bernard's Avatar
bernard bernard is offline
ZeroC Staff
 
Name: Bernard Normier
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Palm Beach Gardens, FL
Posts: 834
I'd also recommend to read my article "Ice and Character Encoding" in issue 16 of the Connections.

Cheers,
Bernard
__________________
Bernard Normier
ZeroC, Inc.
Reply With Quote
  #9 (permalink)  
Old 12-21-2006
tangxiaoshu tangxiaoshu is offline
Registered User
 
Name: tang xiaoshu
Organization: snda
Project: ice java client
 
Join Date: Dec 2006
Posts: 5
Quote:
Originally Posted by bernard View Post
I'd also recommend to read my article "Ice and Character Encoding" in issue 16 of the Connections.

Cheers,
Bernard
I see.

Cheers,
Koko
Reply With Quote
  #10 (permalink)  
Old 12-25-2006
jerrylucky jerrylucky is offline
Registered User
 
Name: ruan shudong
Organization: HUST
Project: wap web site
 
Join Date: Nov 2006
Posts: 14
it seems that every chinese have this problem...

infact, use stringconvert, you can resolve this problem gracefully.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Encoding Problem about Chinese, client compiled by Java, server compiled by C++ richardma Help Center 6 12-21-2005 12:00 AM
encoding error when Ice java client get string from Ice c++ server casper Help Center 1 09-16-2005 04:01 AM
Q on Data encoding ChMeessen Comments 3 01-28-2005 10:19 AM
Client.exe run error in VirtualPC Win98 chenhong_sz Help Center 3 01-28-2005 06:37 AM
IceSSL encoding nsns Bug Reports 4 01-26-2005 05:03 AM


All times are GMT -4. The time now is 12:52 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.