If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Extra conversion to UTF-8 via ODBC

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-23-09, 06:58
mac22 mac22 is offline
Registered User
 
Join Date: Nov 2009
Posts: 3
Extra conversion to UTF-8 via ODBC

I have DB2 v8.1.17.789 on Windows. I inherited a MFC non-Unicode multilingual application that connects to UTF-8 database (codeset UTF-8, territory SI, Slovenia). Strings that are sent through ODBC are UTF-8 strings (non-orthodox approach, but at this time I can't turn my application to Unicode).

In DB2 Control Center I see strings as "raw", garbled if characters are outside ASCII range. This is because the string is converted between my app and database (probably by ODBC driver) from system code page to UTF-8.

Is there a way to prevent this conversion? I would like to have nice strings in database, and to be able to accurately verify lengths before I send strings to database.

I'm not versed to DB2, but I suspect there might be some setting on ODBC part, or DB2 part, with which this can easily be accomplished. All I want is to make DB2 realize it already gets UTF-8 string, no need to convert them.
Reply With Quote
  #2 (permalink)  
Old 11-23-09, 08:04
sawangupta sawangupta is offline
Registered User
 
Join Date: Nov 2009
Location: Bangalore
Posts: 25

Last edited by sawangupta; 11-23-09 at 22:23. Reason: Link corrected
Reply With Quote
  #3 (permalink)  
Old 11-23-09, 09:02
mac22 mac22 is offline
Registered User
 
Join Date: Nov 2009
Posts: 3
I have set the DB2CODEPAGE environment variable to 1208 (System Properties > Advanced > Environment Variables), and restarted my applications, but nothing has changed, the strings are still garbled. One remark: even though the CODESET is set to UTF-8 in the database, the CODEPAGE value is empty.
Reply With Quote
  #4 (permalink)  
Old 11-23-09, 09:47
mac22 mac22 is offline
Registered User
 
Join Date: Nov 2009
Posts: 3
Problem solved. Instead of environment variable I had to use "db2set DB2CODEPAGE=1208". I guess this is because the database is on the same computer as the application.

Sawangupta, thank you for your response, it was helpful. BTW, your first link is broken.
Reply With Quote
Reply

Tags
conversion, db2, odbc, utf8

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On