0

Possible Duplicate:
php mysql character set: storing html of international content

I am wondering should I store my accent (ë, é, è...) as HTML-ENTITIES such as ë or directly as it in my mysql database?

I plan to use it mostly to echo them with php or search it for through a php search engine.

What are the pros and cons?

Community
  • 1
  • 1
Wistar
  • 3,770
  • 4
  • 45
  • 70
  • I don't think there is a pros/cons of submitting accented letters characters – samayo Dec 14 '12 at 20:32
  • 2
    Please, please, please, as they are, not converted for HTML. What happens if you want to use them in a non-HTML context? And note, most characters don't need entities if you are using a character set that has them, utf-8 for instance. – Wrikken Dec 14 '12 at 20:32
  • http://www.joelonsoftware.com/articles/Unicode.html + rule of thumb -> MySql DB + table `utf8_general_ci`, utf8 connection via the `SET NAMES utf8` (http://stackoverflow.com/questions/2159434/set-names-utf8-in-mysql) and meta charset header utf-8 and you go something going – JF Dion Dec 14 '12 at 20:58

1 Answers1

0

Store them in valid encoding with no convertation to HTML entities. Sorting and comparation will work well in database thanking to Character Sets and Collations.

It is always good practice to encode values in echo-time (post processing). But filtering (strip tags as an example) should be done before save (pre processing).

Valera Leontyev
  • 1,191
  • 6
  • 14