This is my first question on the site
An application that I am writing reads an RTF document I supply but I have no control over the RTF's content. In the RTF data, it contains special characters such as the Euro symbol (¬ - ANSI 128)
My application parses the RTF and outputs it as XSL:FO. A later step renders the XSL:FO into a PDF document. The problem is that, from what I've found, the special characters need to be converted to their UNICODE equivalents in order for them to appear in the pdf correctly. Based on a table found here: http://www.alanwood.net/demos/ansi.html
, I can see that the unicode number equivalent for the Euro (ANSI 128) is 8364.
In C#, how do I convert a ANSI number to a Unicode number? I've tried the attached code bit, but it is just changing encoding types of the numbers, and not actually converting them.
Failing that, is there another way to output characters in FO such that I can use their ANSI number instead of their unicode number? Here is how I output a ® in FO (ANSI and Unicode number 174)
<fo:inline font-size="0.50em" baseline-shift="super" font-family="Times New Roman" color="#000000">®</fo
Attached is a .fo file with multiple special characters in it to show what I am trying to do, saved as a .txt file due to file upload restrictions on this site. I am using RenderX's XEP rendering engine to eventually render from XSL:FO to PDF which is where I can tell the characters arn't translating correctly.
System.Text.Encoding ansi = System.Text.Encoding.Default;
System.Text.Encoding unicode = System.Text.Encoding.UTF8;
byte ansibytes = ansi.GetBytes(MyAnsiCharacterCode);
byte unicodebytes = System.Text.Encoding.Convert(ansi, unicode, ansibytes);
char unicodechars = new char[unicode.GetCharCount(unicodebytes, 0, unicodebytes.Length)];
unicode.GetChars(unicodebytes, 0, unicodebytes.Length, unicodechars, 0);
string unicodestring = new string(unicodechars);