-2

I want to be able to store every character possible (Chinese, Arabic, these kind of characters: ☺♀☻) in a MySQL database and also be able to use them in PHP and HTML. how do I do this?

Edit: when I use the function htmlspecialchars() with those characters: ☺♀☻ like this: htmlspecialchars('☺♀☻', ENT_SUBSTITUTE, 'UTF-8'); it returns some seemingly random characters. how do I solve this?

  • 1
    Is this what you actually want? A massively cut-down copy of the Unicode codepoint list? – Phylogenesis Apr 22 '14 at 14:02
  • In order to clarify my point above, I'm not sure such a table would make any sense. Many codepoints are useless on their own. Some affect the text flow around the character, such as U+200E (LEFT-TO-RIGHT MARK) and U+200F (RIGHT-TO-LEFT MARK); others change the preceding characters, such as U+0300 (COMBINING GRAVE ACCENT) and U+0301 (COMBINING ACUTE ACCENT). Unfortunately, storing all these in a database without the relevant metadata is practically useless. – Phylogenesis Apr 22 '14 at 14:28
  • possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – Marcus Adams Apr 22 '14 at 14:32

2 Answers2

0

Use UTF-8 character encoding for all text/var fields in your database, as well as page encoding. Be sure to use multibyte (mb_*) forms of text functions, such as mb_substr().

Phil Perry
  • 2,126
  • 14
  • 18
0

Pick a character set that has the characters you want. utf-8 is very broad most commonly used.

Storing the characters is not so much a problem since it's all just binary data. If you also want the text to be searchable then picking the right collation is useful. utf8_general_ci is fine.

Halcyon
  • 57,230
  • 10
  • 89
  • 128