smart-quotes

How do I convert Word smart quotes and em dashes in a string?

瘦欲@ 提交于 2019-12-27 20:14:06
问题 I have a form with a textarea. Users enter a block of text which is stored in a database. Occasionally a user will paste text from Word containing smart quotes or emdashes. Those characters appear in the database as: –, ’, “ ,†What function should I call on the input string to convert smart quotes to regular quotes and emdashes to regular dashes ? I am working in PHP. Update: Thanks for all of the great responses so far. The page on Joel's site about encodings is very informative:

How do i get rid of all the smart quotes while parsing a web page?

喜你入骨 提交于 2019-12-24 02:23:58
问题 This is my code : name = namestr.decode("utf-8") name.replace(u"\u2018", "").replace(u"\u2019", "").replace(u"\u201c","").replace(u"\u201d", "") This doesn't seem to work . I still find &ldquo , &rdquo etc in my text. Also this text has been parsed using beautiful soup 回答1: Replace the last line of your code with this one: name = name.replace(u"\u2018", "").replace(u"\u2019", "").replace(u"\u201c","").replace(u"\u201d", "") The replace method returns a modified string but it does not affect

How could ASP server-side code corrupt a smart quote ’?

▼魔方 西西 提交于 2019-12-24 01:33:29
问题 My company just converted many columns from varchar to nvarchar. Now it seems that when we render a smart quote (i.e. ALT+0146 ’) to the screen and then send it back to the SQL Server 2000 database for persistence, the smart quote gets corrupted to - ’ -. My Question: How could ASP server-side code corrupt a smart quote ’ ? EDIT: It appears that my question is similar to this one. Incidentally, Powerpoint content introduced the smart quote into the mix. However as I said before, I'm dealing

C++ How to replace unusual quotes in code

家住魔仙堡 提交于 2019-12-23 15:24:06
问题 sometimes when you copy code from a document it gets line numbers and strange quotes. I've written a script to remove those initial numbers but it is very hard to find a way to remove those strange quotes ‘’“” so I've included my full code. It reads in a file and puts out a formatted file. But the compiler warns that these quotes are multi characters, which I guess means non standard ascii chars. It kinda works but it's not a great solution. Any help appreciated: #include <iostream> #include

Converting ″Straight Quotes″ to “Curly Quotes”

走远了吗. 提交于 2019-12-17 22:25:18
问题 I have an application which uses a Javascript-based rules engine. I need a way to convert regular straight quotes into curly (or smart) quotes. It’d be easy to just do a string.replace for ["] , only this will only insert one case of the curly quote. The best way I could think of was to replace the first occurrence of a quote with a left curly quote and every other one following with a left, and the rest right curly. Is there a way to accomplish this using Javascript? 回答1: You could replace

MySQL choking on curly (smart) quotes

拈花ヽ惹草 提交于 2019-12-12 09:37:15
问题 I'm inserting some data into a database from a form. I'm using addslashes to escape the text (have also tried mysql_real_escape_string with the same result). Regular quotes are escaped, but some other quotes are not. For example, the string: Homer's blood becomes the secret ingredient in Moe’s new beer. is converted to: Homer\'s blood becomes the secret ingredient in Moe’s new beer. I didn't think the curly quote would matter unescaped, but only this text is inserted into the database: Homer

how to get smart quotes on org-mode export?

牧云@^-^@ 提交于 2019-12-12 08:37:24
问题 How do I get Emacs org-mode to create proper typographic marks when I export to HTML, including converting straight quotes to smart quotes ("curly quotes") and converting hyphens --- to m-dashes — ? 回答1: #+LANGUAGE: de #+OPTIONS: ':t also does the right thing now 回答2: This is only available in very recent versions of org-mode. If you are not already running the latest git version see http://orgmode.org/worg/org-faq.html#keeping-current-with-Org-mode-development for instructions on upgrading.

MySQL choking on curly (smart) quotes

╄→尐↘猪︶ㄣ 提交于 2019-12-05 04:14:00
I'm inserting some data into a database from a form. I'm using addslashes to escape the text (have also tried mysql_real_escape_string with the same result). Regular quotes are escaped, but some other quotes are not. For example, the string: Homer's blood becomes the secret ingredient in Moe’s new beer. is converted to: Homer\'s blood becomes the secret ingredient in Moe’s new beer. I didn't think the curly quote would matter unescaped, but only this text is inserted into the database: Homer's blood becomes the secret ingredient in Moe So PHP thinks the curly quote is fine, but MySQL is losing

replace MSWord smart quotes in asp.net webform

与世无争的帅哥 提交于 2019-12-02 16:46:44
问题 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? 回答1: 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","\"") 回答2: What are my options to replace these with standard quotes? The best

replace MSWord smart quotes in asp.net webform

匆匆过客 提交于 2019-12-02 08:39:00
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? 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","\"") 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