Subject Re: [firebird-support] charset question
Author Helen Borrie
At 05:42 PM 12/12/2003 +0800, you wrote:
>I have an existing field in a table that its charset is set none. This
>field is use for input chinese characters or alphanumeric character.
>What will happen if I change this field charset to GB_2312? What will
>happen to the chinese characters in it?

They will still be output as garbage. Character set NONE doesn't support
2-byte characters. There is something you can try, to recover the data.


>Any chinese programmer here? I have a application where in the user
>input chinese character, after that the application could export it to
>excel. I using NJ Star Communicator to input/view chinese character.
>Everthing works fine under english windows enviroment until one day the
>excel file produce by the application can not be very correctly under
>chinese windows. The chinese characters where like garbage characters
>instead. Why? Has the charset has something to do with this?

Yes. It's possible that some of your Chinese character data might have
been truncated...but...if you want to experiment with something, take a
backup of the database and restore it somewhere safely away from the main
database. Work on the restored copy. If it won't restore (because of
transliteration errors) then shut down the server and make a file copy to
work on instead.

Pick a table that has one of these problem varchar columns.

Alter the table, by adding two new columns, each having the same number of
characters, same number of characters as the problem column: one as
character set OCTETS, the other as character set GB_2312. Suppose the
problem column is charcol varchar(40):

alter table yourtable
add oct varchar(40) character set OCTETS,
add gb2 varchar(40) character set GB_2312;
commit;
update yourtable
set oct = cast(charcol as varchar(40) character set OCTETS)
where badcol is not null;
commit;
update yourtable
set gb2 = cast(oct as varchar(40) character set GB_2312)
where oct is not null;
commit;

At this point, run some test output from yourtable to see how the data in
gb2 looks to your excel application. If it's OK, then do
alter table yourtable
drop charcol,
drop oct;
commit;
alter table yourtable
add charcol varchar(40) character set GB_2312;
commit;
update yourtable
set charcol = gb2;
commit;

Test charcol. If all is OK, you can then drop gb2.

If you keep the database having character set NONE, you will have to cast
every input to the character columns that need to take Chinese
characters. If most or all of them need to be GB_2312, then consider
rebuilding the database with the correct default character set. Clients
will then need to connect using the same character set.

/h