Storing ampersand in database

后端 未结 2 809
长情又很酷
长情又很酷 2021-01-23 09:26

I am currently working with an sql 2008 database. Many of the entries have ampersands stored thusly \'Arts & Culture\' Should we be storing the escaped version in the databa

2条回答
  •  无人共我
    2021-01-23 10:10

    Generally speaking, everything in a database should be stored as close to original version as possible. If you have to do any escaping, do it outside the DB.

    Reason for doing so is simple: it's only in web where you have to esape the & sign. If you will sometime have a non-web front-end to your DB, you will have to convert these escape sequences back to original value, which is not always possible: for example, if a user will enter & (sic), upon reconversion this will be translated back to &, which will lose original meaning.

提交回复
热议问题