matching against words with accent marks, umlauts, etc. mysql/php

后端 未结 1 1261
时光取名叫无心
时光取名叫无心 2020-12-20 08:57

I\'ve got a website for which I just wrote a great search function. I just realized that I have some words in my db with accent marks. So when somebody types in the word to

相关标签:
1条回答
  • 2020-12-20 09:20

    You need to set a particular collation on your schema so that MySQL knows which characters are supposed to be equivalent. Whether a letter with a diacritical mark is considered the same as one without or some other sequence of characters is language-dependent, but try utf8_general_ci as a starting point for ignoring accents (assuming you're using a UTF-8 character set, which you should be really).

    Try to use the same collation on all your strings, so that they can be joined and compared without expensive, index-breaking conversions.

    0 讨论(0)
提交回复
热议问题