Howto display BIG5 string?

P

Po

Hi,

I have a little piece of code which convert a Chinese(CP_950) string to
Unicode from a network stream.
Actually, it is the sample code which can be found everywhere.

Encoding big5 = Encoding.GetEncoding("big5");
UnicodeEncoding unicode = new UnicodeEncoding();

int nb = ns.Read(data, 0, 255);
System.Diagnostics.Debug.WriteLine("nb: " + nb);

byte[] bba = Encoding.Convert(big5, unicode, data, 0, nb);
reply = unicode.GetString(bba, 0, bba.Length);
System.Diagnostics.Debug.WriteLine("reply[" + reply.Length + "]: " +
reply);

It works fine on my Desktop PC but it failed in the Dopod 900 which running
WM5.

Any help ?

Po
 
A

Alan J. McFarlane

I have a little piece of code which convert a Chinese(CP_950) string
to Unicode from a network stream. [...]
It works fine on my Desktop PC but it failed in the Dopod 900 which
running WM5.
As Fabien asked, does it produce an error, and if so at which line?

When I run similar code on the emulator I get:
System.PlatformNotSupportedException was unhandled
Message="PlatformNotSupportedException"
at
mscorlib.dll!System.Text.Encoding.GetDataItem() + 0x34 bytes
mscorlib.dll!System.Text.CodePageEncoding.CodePageEncoding(int
codepage = 0x000003b6) + 0x17 bytes
mscorlib.dll!System.Text.Encoding.GetEncoding(int codepage =
0x000003b6) + 0xd6 bytes
mscorlib.dll!System.Text.Encoding.GetEncoding(string name = "big5") +
0x1f bytes
SdpBrowserPPC.exe!SdpBrowserPPC.Form1.GetBig5() Line 840 Basic

So there's bno big5 support on my installation. Maybe your device has
Chinese language support.

If so try the simpler:
reply = big5.GetString(data, 0, nb);
Don't do a separate Encoding.Convert.
 
P

Po

The problem is not the reading procedure but the file output procedure.
So, that piece of code is working well in my WM5 actually but cannot view.

Thx, all !

Alan J. McFarlane said:
I have a little piece of code which convert a Chinese(CP_950) string
to Unicode from a network stream. [...]
It works fine on my Desktop PC but it failed in the Dopod 900 which
running WM5.
As Fabien asked, does it produce an error, and if so at which line?

When I run similar code on the emulator I get:
System.PlatformNotSupportedException was unhandled
Message="PlatformNotSupportedException"
at
mscorlib.dll!System.Text.Encoding.GetDataItem() + 0x34 bytes
mscorlib.dll!System.Text.CodePageEncoding.CodePageEncoding(int codepage =
0x000003b6) + 0x17 bytes
mscorlib.dll!System.Text.Encoding.GetEncoding(int codepage = 0x000003b6)
+ 0xd6 bytes
mscorlib.dll!System.Text.Encoding.GetEncoding(string name = "big5") +
0x1f bytes
SdpBrowserPPC.exe!SdpBrowserPPC.Form1.GetBig5() Line 840 Basic

So there's bno big5 support on my installation. Maybe your device has
Chinese language support.

If so try the simpler:
reply = big5.GetString(data, 0, nb);
Don't do a separate Encoding.Convert.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top