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.

asked 14 Apr '15, 15:21

flau's gravatar image

flau
11222
accept rate: 0%

edited 17 Apr '15, 02:46

Volker%20Barth's gravatar image

Volker Barth
40.1k361549819


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

permanent link

answered 14 Apr '15, 16:48

Nick%20Elson%20SAP%20SQL%20Anywhere's gravatar image

Nick Elson S...
7.3k35107
accept rate: 32%

converted 17 Apr '15, 02:45

Volker%20Barth's gravatar image

Volker Barth
40.1k361549819

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.

(16 Apr '15, 13:41) flau
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×13

question asked: 14 Apr '15, 15:21

question was seen: 3,888 times

last updated: 17 Apr '15, 02:46