I am having a problem where users are composing some large chunks of text in MS Word, then pasting that in to the online form. These get entered into the DB as an upside down ?. What are my options to replace these with standard quotes?
3 Answers
These smart quotes are a unicode point. All you need is a simple String.Replace to sort them out.
-edit- Something like:
mystring.Replace("\u201C","\"").Replace("\u201D","\"")

- 39,719
- 45
- 189
- 235
-
1The code points for double smart quotes are \u201C and \u201D. \u0080–\u009F are invisible control characters you'll only get if you misinterpret the ‘Windows-1252’ character set as ‘ISO-8859-1’. – bobince Sep 23 '09 at 23:32
What are my options to replace these with standard quotes?
The best approach is not to replace them. People want to use “smart quotes”, let them. They're not aberrations that only exist in MS Word, they're perfectly valid Unicode characters, and if your application isn't storing non-ASCII characters right then there's a whole lot more that will go wrong than just smart quotes.
Use UTF-8 encoding for all your web pages and store your content in a Unicode-capable database (eg. if you are using SQL Server, use NVARCHAR) and you'll not only support smart quotes but also accents and other alphabets.

- 528,062
- 107
- 651
- 834
-
Thanks, I agree is the "best" way. Unfortunately it's posting to an Oracle DB, which the primary Client app is a 3rd Party Sybase app. At some point in that sequence someone is not allowing UTF-8. – Lloyd Sep 24 '09 at 21:59
You should run the input through the HtmlEncode method, which will convert from or to “
and ”
, allowing you to save those and other higher characters to a format that can be saved without hassle.
Should I also mention Joel's post again?

- 26,785
- 5
- 80
- 117