MySQL Forums
Forum List  »  Connector/ODBC

odbc can not get the whole utf8 string
Posted by: cole lin
Date: February 16, 2022 03:04AM

I create a database with utf8:

connect mysql:

#mysql -h 192.168.26.42 -u root -p

mysql> show variables like 'collation_%';
+----------------------+-------------------+
| Variable_name | Value |
+----------------------+-------------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8mb4_bin |
| collation_server | latin1_swedish_ci |
+----------------------+-------------------+
3 rows in set (0.00 sec)

then create a table:

mysql> create table test_tab(f1 int, f2 varchar(25));
Query OK, 0 rows affected (0.12 sec)

insert 1 row:
mysql> insert into test_tab values(1, "沙子沙子沙子沙子沙子");
Query OK, 1 row affected (0.02 sec)

ps:"沙子沙子沙子沙子沙子" is Chinese;

select row:
mysql> select f2 from test_tab where f1 = 1;
+--------------------------------+
| f2 |
+--------------------------------+
| 沙子沙子沙子沙子沙子 |
+--------------------------------+
1 row in set (0.00 sec)

I can get whe whole utf8 string;

##########################################
I config ODBC DSN like that:
[ssodb]
Driver=/usr/lib64/libmyodbc8w.so
SERVER=192.168.26.42
PORT=3306
Database=sso
CHARSET=UTF8

then run:
#isql ssodb root 123456 -v

select row with odbc:
SQL> select f2 from test_tab where f1 = 1;
+--------------------------+
| f2 |
+--------------------------+
| 沙子沙子沙子沙子+--------------------------+
SQLRowCount returns 1
1 rows fetched

I just can get "沙子沙子沙子沙子" but not "沙子沙子沙子沙子沙子";
How i can get the whole utf8 string with ODBC?
It seems ODBC just get 25/3 utf8 character; 25 is the size of column
f2;3 is ths utf8 character size;

ps:
unixODBC version:2.3.7/2.3.9
mysql-connector-odbc version:8.0.15/8.0.28
mysql server version:5.6.39

Options: ReplyQuote


Subject
Written By
Posted
odbc can not get the whole utf8 string
February 16, 2022 03:04AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.