How to Replace Those Very Stupid MS Word Curly Quotes (aka Smart Quotes)
by Erich Peterson
Want to get replace those “smart quotes” that MS Word uses in your .NET code? This will do it:
VB .NET
Dim newstr As String newstr = oldstr.Replace(Chr(147), "& quot;") ' take out extra space b/w & and quot; newstr = newstr.Replace(Chr(148), "& quot;") ' take out extra space b/w & and quot;
C#
string newstr; newstr = oldstr.Replace((char)147, "& quot;") // take out extra space b/w & and quot; newstr = newstr.Replace((char)148, "& quot;") // take out extra space b/w & and quot;
Comments
Does this solution work in C# 1.1? I seem to get an error. It keeps telling me that if I’m replacing a char with a char, or a string with a string, but not a char with a string.
You must be logged in to post a comment.