Informix cli Chinese Character garbled Solution

Source: Internet
Author: User
Tags dsn informix

Since the code set of the informix database is set to a en_us.8859-1, Chinese characters cannot be properly displayed due to this incorrect Character Set setting when using the drivers of csdk 2.8 and later. Here is a thorough solution:

 

The omnipotent Internet must keep this article forever!

 

 

Informix CSDK before 2.8, Garbage In, Garbage Out mode is used by default to process Chinese characters, if DB_LOCALE on the database server uses the default en_us.8859-1 Character Set, can normally support Chinese characters. However, when you upgrade to CSDK2.8 or a later version, Garbage In and Garbage Out modes are no longer supported, and Garbage Out modes may cause garbled characters. In this case, it is recommended to change the character set of the database (set DB_LOCALE = zh_cn.GB18030-2000, re-create the database), and then follow the method described in this article for DB_LOCALE and CLIENT_LOCALE settings. If the cost of rebuilding a database in the actual environment is too high, consider the following steps to solve the problem of ODBC support for Chinese.

Database Server:
1. Set the environment variable IFMX_UNDOC_B168163 = 1; export IFMX_UNDOC_B168163
2. Copy the en_us.8859-1 character set file to the zh_cn directory
Cd $ INFORMIXDIR/gls/lc11
Cp./en_us/0333.lco./zh_cn
3. Restart IDS

Client:
In odbc, you can configure the data source as follows:

DB_LOCALE = zh_cn.GB18030-2000
CLIENT_LOCALE = zh_cn.GB18030-2000

You can also add settings in the connection string:

Dsn = xxx; uid = xxx; pwd = xxx; DLOC = zh_cn.GB18030-2000; CLOC = zh_cn.GB18030-2000;

Using IBM. Data. Informix. IfxConnection, you can set the connection object as follows:

IBM. Data. Informix. IfxConnection conn = new IfxConnection ("DataBase = xxx; Server = xxx; User ID = xxx; Password = xxx ");
Conn. ClientLocale = "zh_cn.GB18030-2000 ";
Conn. DatabaseLocale = "zh_cn.GB18030-2000 ";

For JDBC, we can solve this problem through NEWCODESET:

URLString = "jdbc: Informix-sqli: // 9.125.66.130: 6346/dbname: InformixSERVER = servername;
NEWCODESET = GB18030-2000, 8859-1,819;
CLIENT_LOCALE = en_US.8859-1; DB_LOCALE = en_US.8859-1 ;"

 

In a 64-bit system, there are two odbc managers: 32-bit and 64-bit. Corresponding to different data source drivers. The corresponding manager can only configure and manage data sources of the corresponding version. Data sources of different versions can have duplicate names, that is, a 32-bit "testconn" and a 64-bit "testconn" can exist at the same time. Their connection strings are the same: "dsn = testconn; uid = informix; pwd = xxxxxx"

When you install the informix cli driver on a 64-bit windows system, you can install the 32-bit or 64-bit version, or both, but there may be some conflicts.

When only the 64-bit cli driver is installed, all applications must be compiled into x64 or anycpu (test required ). A 64-bit application can only use a 64-bit cli driver or a 64-bit odbc source.

When only the 32-bit cli driver is installed, all applications must be compiled into the x86 (32-bit) version to run. You can only use a 32-bit odbc data source. For an ASP.net application, you must set "allow 32-bit applications to run" for the application pool in iis ".

On windows server 2008 \ 2008 r2 \ 2012 x64 systems, you can also install x64 and 32-bit cli. However, the installation process, sequence, environment variables, and other issues may cause one of them to fail to connect to the database correctly. We recommend that you handle the following:

The 64-bit cli driver is installed under "c: \ program files.

The 32-bit driver should be installed under "c: \ program files (x86) \". Before installation, you must set a "c: \ windows \ syswow64; "before all projects.

When setting the data source, if a cli data source cannot connect to the database and reports "unable to load translation shared library", set the Translator lib project to "C: \ Program Files \ Informix \ Client-SDK \ bin \ igo4n304. dll "or" C: \ Program Files (x86) \ Informix \ Client-SDK \ bin \ igo4n304. dll ".

 

Finally, it seems that the contents of the site field of tabname = 'gl_collate' or 'gl_ctype 'in the database's "tables" table are directly modified, for example, changing from 'en _ US.819 'to 'zh _ CN.GB18030-2000' can also directly modify the character set settings of the database. It seems that there is no problem after a simple test, but I did not dare to try it again.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.