Groups | Blog | Home
all groups > dotnet general > december 2005 >

dotnet general : .NET: Encoding.Convert(...Encoding.Unicode...)


Ma³y PiotruĊ“
12/8/2005 9:35:55 PM
Hello,
Could you help me please with encoding transformations in .NET? I am
beginner.
I have some code that nearly works - but I have problem with
converting from fileEncoding to Unicode (Strings are in Unicode).

Dim fe As Encoding 'fileEncoding
Dim ue As Encoding = Encoding.Unicode
Dim fb(0) As Byte 'bytes read
Dim ub As Byte() 'output bytes
....
fe = Encoding.GetEncoding(...) 'fe pobierane z Web.configa
....
fb(0) = br.ReadByte() 'here fb(0) > 0
ub = Encoding.Convert(fe, ue, fb) 'ERROR here: ub is null

Could you explain me please why ub does not contain Unicode bytes? How
to correct the code?
Thank you very much.
Jon Skeet [C# MVP]
12/8/2005 10:42:16 PM
[quoted text, click to view]

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--=20
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
AddThis Social Bookmark Button