MYSQL Encoding

So., 01/07/2012 - 20:45
Body
http://stackoverflow.com/questions/3735139/how-to-do-mysql-queries-on-text-with-umlauts-in-drupal

Convert

http://en.gentoo-wiki.com/wiki/Convert_latin1_to_UTF-8_in_MySQL

utf8_general_ci

http://dev.mysql.com/doc/refman/5.1/de/charset-unicode-sets.html
  1. ALTER TABLE term_data CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
WICHTIG:
  1. Ä = A
  2. Ö = O
  3. Ü = U
  4. ß = s
The problem is that since the node table and the title column have utf8_general_ci collation, MYSQL does not treat o and ö umlaut differently and this query returns nodes starting with O AND nodes starting with Ö

Tips

  1. SELECT * FROM `term_data` WHERE name='Boden1' COLLATE utf8_bin
  2. if($result = db_query("SELECT tid FROM {term_data} WHERE vid = '%d' AND name = '%s' COLLATE utf8_bin", $vid, $termname) )
Webdevelopment
Add new comment
The content of this field is kept private and will not be shown publicly.

Plain text

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <drupal-entity data-*>
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.