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

前端 未结 13 1761
星月不相逢
星月不相逢 2020-11-29 03:11

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 em

13条回答
  •  星月不相逢
    2020-11-29 03:47

    It sounds like the real problem is that your database is not using the same character encoding as your page (which should probably be UTF-8). In that case, if any user submits a non-ASCII character you'll probably see weird characters in the database. Finding and fixing just a few of them (curly quotes and em dashes) isn't going to solve the real problem.

    Here is some info on migrating your database to another character encoding, at least for a MySQL database.

提交回复
热议问题