RTF character set to codepage?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SiliconJaltz
    New Member
    • May 2007
    • 2

    RTF character set to codepage?

    Hi,

    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.

    Code:
     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);
    Any help appreciated.
    John
Working...