MySQL的ANSI和Unicode驱动程序之间的差异。

时间:2021-07-25 21:28:52

On choosing Data Source under ODBC (64-Bit) on Windows, i get two available options of MySQL Database:

在Windows上使用ODBC(64位)选择数据源时,我得到了MySQL数据库的两个可用选项:

  • MySQL ODBC 5.3 ANSI Driver
  • MySQL ODBC 5.3 ANSI驱动程序
  • MySQL ODBC 5.3 Unicode Driver
  • MySQL ODBC 5.3 Unicode驱动程序。

What are the difference between these two?

这两者之间有什么区别?

2 个解决方案

#1


16  

Firstly I should say that I don't use MySQL but I do know about ODBC Drivers. In ODBC there are different APIs for unicode and ansi. The ansi APIs end in A and the unicode APIs end in W (e.g., SQLPrepareA and SQLPrepareW). The ansi APIs accept bytes/octets for character strings and hence can only handle chrs 0-255. The unicode APIs accept SQLWCHARs which are 2 byte UCS-2 encoded unicode codepoints (newer MS SQL Server versions can handle UTF16 encoded strings) and so can handle approximately the first 65000 codepoints in unicode.

首先,我应该说我不使用MySQL,但是我知道ODBC驱动程序。在ODBC中,有不同的unicode和ansi api。ansi api以A结尾,unicode api以W结尾(例如,SQLPrepareA和SQLPrepareW)。ansi api接受字符字符串的字节/八进制,因此只能处理chrs 0-255。unicode api接受SQLWCHARs,它是2字节的UCS-2编码的unicode编码点(更新的MS SQL Server版本可以处理UTF16编码的字符串),因此可以在unicode中处理大约第65000个代码点。

So if you need to store unicode data you have no choice which driver to use.

因此,如果需要存储unicode数据,就无法选择使用哪个驱动程序。

I would not let the comments on speed from Carnangel put you off using the unicode driver and in any case his comments do not include any facts. He may be referring to:

我不会让Carnangel关于速度的评论妨碍您使用unicode驱动程序,无论如何,他的评论不包含任何事实。他可能指的是:

If you store unicode data in MySQL it will be UTF-8 encoded and transferred over your network as UTF-8. At the client end the ODBC driver will have to convert the UTF-8 encoded data into UCS-2 as this is what ODBC needs. Obviously the reverse applies.

如果您将unicode数据存储在MySQL中,它将被UTF-8编码并以UTF-8的形式通过网络传输。在客户端,ODBC驱动程序必须将UTF-8编码的数据转换成UCS-2,因为这是ODBC需要的。显然相反的适用。

If you write an ANSI ODBC application (that is one which uses the ansi ODBC apis) with a unicode ODBC driver then the ODBC Driver manager will have to convert the UCS-2 the driver returns to 8 bit (lossy) and convert the 8 bit data you pass to the driver to UCS-2. So don't do that.

如果你写一个ANSI ODBC应用程序(这是一个使用ANSI ODBC api)与unicode ODBC驱动程序然后ODBC驱动程序管理器将不得不ucs - 2司机返回转换为8位(损耗)和转换为8位数据传递给司机ucs - 2。所以不要这样做。

These days I'd be surprised if anyone is still using ANSI ODBC drivers.

如今,如果有人还在使用ANSI ODBC驱动程序,我会感到惊讶。

#2


3  

As you may know Ansi and unicode are applied to the data character type. You can choose one or the other, it is not a question of processor Here is the difference between them: - Unicode allow you to have all the characters properties enabled but reducing raw speed treatment - Ansi, the opposite, less character type but raw speed treatement will speed up

您可能知道,Ansi和unicode应用于数据字符类型。你可以选择其中一个或另一个,这不是处理器的问题,这是它们之间的区别:- Unicode允许你启用所有字符属性,但减少原始速度处理- Ansi,相反,较少字符类型,但原始速度处理将加快

If you are a new user take the Unicode one, if not you can choose the Ansi one.

如果您是一个新用户,请选择Unicode one,如果不是,您可以选择Ansi one。

I hope you've got the point ;)

我希望你已经明白了。

#1


16  

Firstly I should say that I don't use MySQL but I do know about ODBC Drivers. In ODBC there are different APIs for unicode and ansi. The ansi APIs end in A and the unicode APIs end in W (e.g., SQLPrepareA and SQLPrepareW). The ansi APIs accept bytes/octets for character strings and hence can only handle chrs 0-255. The unicode APIs accept SQLWCHARs which are 2 byte UCS-2 encoded unicode codepoints (newer MS SQL Server versions can handle UTF16 encoded strings) and so can handle approximately the first 65000 codepoints in unicode.

首先,我应该说我不使用MySQL,但是我知道ODBC驱动程序。在ODBC中,有不同的unicode和ansi api。ansi api以A结尾,unicode api以W结尾(例如,SQLPrepareA和SQLPrepareW)。ansi api接受字符字符串的字节/八进制,因此只能处理chrs 0-255。unicode api接受SQLWCHARs,它是2字节的UCS-2编码的unicode编码点(更新的MS SQL Server版本可以处理UTF16编码的字符串),因此可以在unicode中处理大约第65000个代码点。

So if you need to store unicode data you have no choice which driver to use.

因此,如果需要存储unicode数据,就无法选择使用哪个驱动程序。

I would not let the comments on speed from Carnangel put you off using the unicode driver and in any case his comments do not include any facts. He may be referring to:

我不会让Carnangel关于速度的评论妨碍您使用unicode驱动程序,无论如何,他的评论不包含任何事实。他可能指的是:

If you store unicode data in MySQL it will be UTF-8 encoded and transferred over your network as UTF-8. At the client end the ODBC driver will have to convert the UTF-8 encoded data into UCS-2 as this is what ODBC needs. Obviously the reverse applies.

如果您将unicode数据存储在MySQL中,它将被UTF-8编码并以UTF-8的形式通过网络传输。在客户端,ODBC驱动程序必须将UTF-8编码的数据转换成UCS-2,因为这是ODBC需要的。显然相反的适用。

If you write an ANSI ODBC application (that is one which uses the ansi ODBC apis) with a unicode ODBC driver then the ODBC Driver manager will have to convert the UCS-2 the driver returns to 8 bit (lossy) and convert the 8 bit data you pass to the driver to UCS-2. So don't do that.

如果你写一个ANSI ODBC应用程序(这是一个使用ANSI ODBC api)与unicode ODBC驱动程序然后ODBC驱动程序管理器将不得不ucs - 2司机返回转换为8位(损耗)和转换为8位数据传递给司机ucs - 2。所以不要这样做。

These days I'd be surprised if anyone is still using ANSI ODBC drivers.

如今,如果有人还在使用ANSI ODBC驱动程序,我会感到惊讶。

#2


3  

As you may know Ansi and unicode are applied to the data character type. You can choose one or the other, it is not a question of processor Here is the difference between them: - Unicode allow you to have all the characters properties enabled but reducing raw speed treatment - Ansi, the opposite, less character type but raw speed treatement will speed up

您可能知道,Ansi和unicode应用于数据字符类型。你可以选择其中一个或另一个,这不是处理器的问题,这是它们之间的区别:- Unicode允许你启用所有字符属性,但减少原始速度处理- Ansi,相反,较少字符类型,但原始速度处理将加快

If you are a new user take the Unicode one, if not you can choose the Ansi one.

如果您是一个新用户,请选择Unicode one,如果不是,您可以选择Ansi one。

I hope you've got the point ;)

我希望你已经明白了。