a*p 发帖数: 62 | 1 seems that mysql will add unicode support in the near future.
when I query like "%猪%"
it will return lots of unrelated items, which might contain the two bytes
of 猪 but not belonging to the same chinese character.
true? |
a*p 发帖数: 62 | 2 没人回答我,赫赫,我自己想了个笨办法:
因为我用的PHP也不支持unicode,我就:
数据库出来的数据再用unicode_like_compare做过滤,应该可以在很大程度上解决问题。
这个应该还是暂时方案吧,等mysql的unicode support吧。
function to_unicode_like($str) {
$r = "";
for ($i=0;$i
$ch = substr($str,$i,1);
if (ord($ch) < 127) $r .= " $ch";
else {
if ($i == strlen($str)-1) $r .= $ch;
else {
$r .= substr($str,$i,2);
【在 a*p 的大作中提到】 : seems that mysql will add unicode support in the near future. : when I query like "%猪%" : it will return lots of unrelated items, which might contain the two bytes : of 猪 but not belonging to the same chinese character. : true?
|
b****e 发帖数: 1275 | 3 oracle supports unicode directly.. for databases
that do not support unicode i would always base64encode
the string before storing it into the db.. to do a compare
base64encode the "pig" first too of course
【在 a*p 的大作中提到】 : 没人回答我,赫赫,我自己想了个笨办法: : 因为我用的PHP也不支持unicode,我就: : 数据库出来的数据再用unicode_like_compare做过滤,应该可以在很大程度上解决问题。 : 这个应该还是暂时方案吧,等mysql的unicode support吧。 : function to_unicode_like($str) { : $r = ""; : for ($i=0;$i: $ch = substr($str,$i,1); : if (ord($ch) < 127) $r .= " $ch"; : else {
|
a*p 发帖数: 62 | 4 I thought this solution before.:-)
but how to deal with where blah like '%pig%'? that's what I need.
【在 b****e 的大作中提到】 : oracle supports unicode directly.. for databases : that do not support unicode i would always base64encode : the string before storing it into the db.. to do a compare : base64encode the "pig" first too of course
|