[jdev] SASL debugging

Chris Mullins chris.mullins at coversant.net
Sat Dec 10 13:56:30 CST 2005

Norman Rasmussen Wrote:

> As you found, sometimes the .net framework actually does 
> a utf-16 encoding when you ask it for utf-8.  This has 
> nailed me recently when trying to use webservices.  

All strings in .NET are UTF-16 encoded. This is the way .NET works.
Likewise strings in Windows (NT, 2000, XP, 2003, Vista, etc) are also
UTF-16 encoded. 

The only way to directly manipulate UTF-8 is using byte arrays. As soon
as you put things into .NET strings, they are going to be encoded using

The various encoders in .NET (UTF-8, UTF-16, UTF-32, and a few others)
can all convert from a string to a byte array and back. 

> I ended up having to add and remove the 'marker' bytes 
> (0xff, 0xfe) at the front of the byte array to get it
> to work properly.

My guess is that you're doing something wrong. I've never had to do
this, and I've done quite a bit of work with the various encodings of
Unicode in .NET.

Chris Mullins

More information about the JDev mailing list