erdomke / RtfPipe

Library for processing rich-text format (RTF) streams
MIT License
121 stars 44 forks source link

Problems with spanish chars. #31

Closed giorgiozoppi closed 3 years ago

giorgiozoppi commented 5 years ago

Hello, i have a problem in ASP.net with Spanish chars in rtf. I am fetching the params from the db. Example the rtf A continuaci#f3n should be translated in html with ó

private string ToHtml(string text) { if (string.IsNullOrEmpty(text)) { return string.Empty; } if (text.StartsWith(@"{\rtf1")) { var correction = Rtf.ToHtml(text);; // i have to change this. correction = correction.Replace("f3", "ó"); correction = correction.Replace("e1", "é"); return correction; } var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(text); if (htmlDocument.ParseErrors.Any()) { return text; } // if it is an invalid html we treat as html. return "

" + text + "

"; }

erdomke commented 5 years ago

Can you send me an example of the document? As a side note, with non-ASCII (that is non-English) characters, RTF tends to work better when read from a stream than from a string. However, I can help more if I have an example of the document. Thanks!