Converting Microsoft Word Smart Quotes to Straight Quotes

Posted by curiousR on Stack Overflow See other posts from Stack Overflow or by curiousR
Published on 2011-06-25T00:38:23Z Indexed on 2011/06/25 8:22 UTC
Read the original article Hit count: 436

Filed under:
|

We have a program where the user needs to do a Copy-Paste some content from Microsoft Word into a HTML editor (Visual Studio 2008).

That content in the HTML is then used in our confirmation emails.

Some of the characters like curly quotes turn into ? on the browser & in our confirmation email.

For the browser... I was able to find how to resolve this issue by using jQuery.

But for the confirmation email I cannot use JavaScript.

I tried this ASP.net / C# code but it hasn't worked for me.

if (s.IndexOf('\u201b') > -1) s = s.Replace('\u201b', '\'');
if (s.IndexOf('\u201c') > -1) s = s.Replace('\u201c', '\"');
if (s.IndexOf('\u201d') > -1) s = s.Replace('\u201d', '\"');
if (s.IndexOf('\u201e') > -1) s = s.Replace('\u201e', '\"');

I would appreciate any help in resolution.

Thanks.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET