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

  • Thread starter Thread starter Ma³y Piotruœ
  • Start date Start date
M

Ma³y Piotruœ

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.
(MP)
 
Ma³y Piotru? said:
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?

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.
 
Back
Top