By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,190 Members | 1,469 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,190 IT Pros & Developers. It's quick & easy.

RTF character set to codepage?

P: 2

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
  1.  Encoding srcEncoding = Encoding.GetEncoding(nSourceCodePage);
  2.                InBytes = new byte[2];
  3.                InBytes[0] = nFirstDoubleByte;
  4.                InBytes[1] = (byte)node.Parameter;
  5. //and convert to Unicode
  6.               Encoding unicodeEncoding = Encoding.GetEncoding(1200);
  7.               byte[] outputBytes = UnicodeEncoding.Convert(srcEncoding, unicodeEncoding, InBytes);
  8.              string unicodestring = System.Text.Encoding.Unicode.GetString(outputBytes);
Any help appreciated.
Mar 16 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.