On Db2 v11.5.7 on Linux/x86_64 I have a UTF-8 database.

Executing db2 get db cfg for test1 returns:

 Database code page       = 1208
 Database code set        = UTF-8

On my Windows 10 computer in Putty I have set: Window | Translation | Remote character set to UTF-8. I can properly see non-English characters in Putty.

I have also installed DBeaver tool and I can also properly see non-English characters.

The problem I have is "db2cmd" tool.

In Putty remote connection I created tables and inserted one character:

db2 "connect to test1 user db2inst1 using db2inst1"
db2 "create table admin.test8 (id int not null generated always as identity, a varchar(20))"
db2 "insert into admin.test8 (a) values ('č')"
db2 "select id, a, hex(a) as hex_a from admin.test8 order by id"

Output of select statement is (which is correct):

enter image description here

If I do the same in DBeaver:

insert into admin.test8 (a) values ('č');
select id, a, hex(a) as hex_a from admin.test8 order by id;

I get:

enter image description here

Both Putty and DBeaver correctly inserts character in database.

Now saving the commands into UTF-8 encoding:

enter image description here

From db2cmd I check for the code page:


and output is:

Active code page: 1252

Execute commands: db2 -tf a.sql

enter image description here

Output in column A is completely wrong. In ID=3 also HEX_A is completely wrong.

I tried several things like:

  1. Changing: chcp 65001
  2. db2set DB2CODEPAGE=1208

But in both cases I see the same result as last command.

If I try to connect with "-a" switch I get Db2 server code page is 1208 (utf-8) and Db2 client code page is 1252.

enter image description here

Now to configure db2cmd to properly handle the UTF-8 code-page?

  • What does locale return when you run it as the user that connects to the database? Commented Oct 19, 2022 at 12:18
  • Interesting question. Not an answer, but have you tried with PowerShell (not the same but close)? What about a local terminal from Mobaxterm or similar tool?
    – AngocA
    Commented Oct 19, 2022 at 16:03

1 Answer 1


I haven't tried to set the system default locale to UTF-8 (don't want to risk).
db2 clp on Windows doesn't work normally with terminal input and output.
But you may make it produce correct UTF-8 output into a file or accept correct UTF-8 input with the following. It's important to run db2 terminate after setting DB2CODEPAGE.
True Type font must be used in the terminal.

set DB2CODEPAGE=1208
chcp 65001
db2 terminate
db2 connect to mydb

rem garbled terminal output, correct file output
db2 -r utf8.log "values U&'\0141\00F3d\017A is a city in Poland'"
echo values 'Łódź is a city in Poland' | db2 -r utf8.log +p -

rem some "translated" terminal & file output (Ł -> L, ó -> o)
db2 -r utf8.log "values 'Łódź is a city in Poland'"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.