在SQLite中使用UTF8 INSTR

时间:2013-03-21 09:00:34

标签: unicode utf-8 sqlite

我正在尝试在SQLite中使用INSTR函数,但它返回错误的值如果我使用UTF8字符。我该如何避免这个问题?

select instr('akçe', 'a'); --returns 1 (Correct)
select instr('akçe', 'k'); --returns 2 (Correct)
select instr('akçe', 'ç'); --returns 0 (Wrong)
select instr('akçe', 'e'); --returns 3 (Wrong)

1 个答案:

答案 0 :(得分:1)

适合我:

> select instr('akçe', 'ç');
3
> select instr('akçe', 'e');
4

显然,你实际上并没有使用UTF-8。

检查select quote(cast('ç' as blob));的输出是否为X'C3A7'