I'm trying to convert some RTF text to Unicode UTF-16.
The characters I'm converting are double byte Japanese.
The character set is fcharset128 which should be codepage 932.
I am looking for a way to ask .NET given a character set for it to return the correct codepage or encoding.
How do I map the character set 128 to the correct codepage?
With other languages RTF gives the codepage, so its a simple matter of retrieving the encoding..e.g. normal codepage for english is 1252, so nSourceCodePage = 1252.
Expand|Select|Wrap|Line Numbers
- Encoding srcEncoding = Encoding.GetEncoding(nSourceCodePage);
- InBytes = new byte[2];
- InBytes[0] = nFirstDoubleByte;
- InBytes[1] = (byte)node.Parameter;
- //and convert to Unicode
- Encoding unicodeEncoding = Encoding.GetEncoding(1200);
- byte[] outputBytes = UnicodeEncoding.Convert(srcEncoding, unicodeEncoding, InBytes);
- string unicodestring = System.Text.Encoding.Unicode.GetString(outputBytes);
John