doukan4795 2012-06-15 10:35
浏览 28
已采纳

数据库搜索中的语言特殊字符

me working on search in a multilingual site (currently only english and turkish).

As long as visitor uses the correct language characters, search out puts corrent results.

e.g.

  • for word "Moudle" (english) like clause of sql query is like "%Moudle%" and it works fine.
  • for word "modül" (turkish) like clause of sql is like "%modül%" and it works fine.

My problem is that for turkish if i use "modul" rather that "modül", it does not works. Only because of "ü".

Is there any way that i can get results from database even if i use same counterpart characters from english language instead of original?


Structure of table is

CREATE TABLE IF NOT EXISTS post_lang (
  id bigint(20) NOT NULL AUTO_INCREMENT,
  post_id bigint(20) NOT NULL,
  ln enum('en','tr') NOT NULL,
  title text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (id)
);
INSERT INTO post_lang (id, post_id, ln, title, content, doc) VALUES
(1, 1, 'en', 'How can I create a new module?'),
(2, 1, 'tr', 'Nasıl yeni bir modül yaratırım?');
  • 写回答

1条回答 默认 最新

  • dongmeixi5311 2012-06-15 10:47
    关注

    You could create a field say normalizedText where you are going to store only the chars without accents following your logics.

    So you can run a search on your normalizedText with a string not containing accents and having consisent result.

    You can use a handy php wordpress function (remove_accents) that converts your accented chars to non accented chars

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧