cancel
Showing results for 
Search instead for 
Did you mean: 

Reading and display GBK strings

Former Member
0 Kudos
4,366

Windows 7 English Sybase SQL Anywhere 12.0.1.3942

I have a database with char collation set to 936ZHO.

-- Database CHAR collation: 936ZHO, NCHAR collation: UCA -- Connection Character Set: GBK

I have entered Chinese into a char column.

With ISQL, I can see the correct Chinese characters in the output pane. If I access the records via ODBC with ado in VB6 and display the string via a unicode compatible mshflex grid control, the Chinese in the grid is displayed as garbage.

If I changed the database to this:

-- Database CHAR collation: UCA, NCHAR collation: UCA -- Connection Character Set: UTF-8

Chinese again is entered into a char column.

With no changes in code, the Chinese would be displayed correctly in the grid.

How I can read Chinese and display Chinese characters correctly when character set is GBK? Why ISQL is able to display Chinese correctly and ado via ODBC cannot?

Thank you for your help.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member

DBISQL is a java application and that natively uses Unicode (internally UTF32) and so the connection charset will be Unicode (UTF-16 I believe) and the server will translate the characters correctly knowing this.

I believe ADO is going through a generic (OLE/DB to ODBC) bridge and that software is limited and can have issues like this. You could try using the SQL Anywhere OLE/DB driver instead or set up the connection to request CHARSET=UTF-8

Former Member
0 Kudos

Nick,

Thank you for suggesting to use OLE/DB. I added Provider=SAOLEDB to my connection string and Chinese is displaying correctly from a GBK database.