Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UNICODE conversion problem, please help..

Status
Not open for further replies.

Themuppeteer

Programmer
Apr 4, 2001
449
BE
Hello,

I have a C# client that gets a string from a textfield.
This client calls a webservice with as argument the string.
(The webservice is written in C++ with gsoap ..)

When the webservice is called, it prints the stringlength of the recieved string on the screen.
Now when I call my service with a ONE japanese character as argument, the stringlength of the string the webservice recieves is 1. It should be 2 right (because a unicode character is 16 bit)? Apperantly the client cuts of the unicode chars at 8 bits.

Now what I want to do to solve this is convert my string with unicode to another string (twice as long) with the unicode chars split up.

Who can help me ? Who can give me functions/ideas/tips ??

thanks a lot.

Greetz,
muppeteer.gif

NOSPAM_themuppeteer@hotmail.com (for mails, remove the NOSPAM_)

Don't eat yellow snow...and don't mess with your fstab!
 
.NET stores strings internally as UTF-16, which like you said, occupy two bytes. But the Length parameter of the string returns the length in characters, not bytes, so that explains why you were only seeing a "1" for that value.

To covert to a single-byte representation (or, as close as you reasonably can), use the Encoding class to convert your string to UTF-8.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top