>I have a string and I one to convert it to a different encoding, right now I
Quote:
>first convert it to binary and then convert the binary to a string with the
>new encoding.
That doesn't quite make sense. Whenever you have a String object, its
contents is Unicode (UTF-16 basically). So you're not converting to a
string with a new encoding with your GetString call. What you're doing
is saying that the data in the byte array can be interpreted as
encoded with whatever encoding intEncodingPage represents, and
requests that it's converted to a .NET String. Your current code could
easily result in data loss if the byte array content isn't valid
according to the encoding you're using.
If you want to store the text in a specific encoding and not as a .NET
UTF-16 String, you have to keep in in a byte array. So what you
probably want to do is
Dim encodedText() As Byte =
Encoding.GetEncoding(intEncodingPage).GetBytes(str Text1)
Mattias
--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ |
http://www.dotnetinterop.com
Please reply only to the newsgroup.