如何在Firebird sql语句中使用非ascii字符串文字? [英] How to use non-ascii character string literals in firebird sql statements?

查看:141
本文介绍了如何在Firebird sql语句中使用非ascii字符串文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在firebird sql查询中使用非ascii字符串文字. 因此,我使用了 FlameRobin 来看看它是否首先起作用: 我用了这样的东西:

I want to use non-ascii character string literals in a firebird sql query. So I used FlameRobin to see if it works first: I used something like this:

SELECT NAME FROM TABLE1 WHERE NAME = 'العربية'

我也尝试过:

SELECT NAME FROM TABLE1 COLLATE UNICODE_CI_AI WHERE NAME = 'العربية'

没有成功.因为我已经使用 UTF8 字符集和 UNICODE_CI_AI 归类声明了 NAME .

with no success. Because I have declared NAME using UTF8 Character Set and UNICODE_CI_AI Collation.

从此引荐网址链接: https ://firebirdsql.org/file/documentation/reference_manuals/fblangref25-zh-CN/html/fblangref25-appx06-charsets.html

FlameRobin引发有关语法的错误,实际上它不理解:'العربية'字符串. 因此,我决定使用 Firebird Maestro 更改数据库管理工具以进行测试,该工具现在可以接受此类非ascii字符串文字,但过滤器操作不正确.

FlameRobin throws an error about the syntax, it actually don't understand : 'العربية' string. So I decided to change the database administration tool with Firebird Maestro to do the test, this tool now accepts these kind of non-ascii character string literals, but it is not doing the filter properly.

该问题如何解决?

注意:我正在使用Firebird v2.5

推荐答案

Firebird使用连接字符集来知道如何对字符串值进行编码.默认值为NONE,这意味着没有应用特定的字符集转换,并且每个工具/客户端的确切行为也有所不同,但是通常,客户端会应用系统默认的字符集在字节值和字符串之间进行转换.

Firebird uses a connection character set to know how string values need to be encoded. The default is NONE which means that no specific character set conversion is applied, and exact behavior varies per tool/client, but in general clients will apply the system default character set to convert between byte values and strings.

从FlameRobin连接时,您需要指定连接字符集UTF8,您的查询才能正常工作

You need to specify connection character set UTF8 when connecting from FlameRobin, and your query will work

SELECT NAME FROM TABLE1 WHERE NAME = 'العربية'

如果未指定连接字符集,则将应用连接字符集NONE,结果字符串值将以平台默认编码(在Windows上不是utf8,但例如Windows-1252)解释).

If you don't specify a connection character set, then connection character set NONE is applied, and as a result string values will be interpreted in the platform default encoding (which on Windows is not utf8, but for example windows-1252).

这篇关于如何在Firebird sql语句中使用非ascii字符串文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆