I have done some research via google but cant find a proper answer.
I have a Firebird Database and i always using own Domains for my Table fields. All of that domains are defined with Charset ISO8859_1. Now I want to change it to UTF8. If i try this in IBExpert it brings me this code:
ALTER DOMAIN D_CHAR100 TYPE VARCHAR(100) CHARACTER SET UTF8;
This update works. But does it really work? Are all characters converted correctly and do i now have changed my fields to "real" UTF8 ?? Or does it remain as ISO08859_1 internally?
If i search in the internet, some say:
and other say:
What is right? What could go wrong? We have a lot of customers and i want to convert the database by script.
Altering the field does not alter any data inside that field. And it will expose many problems for you down the line. The best way to do this is to copy data, however you have more work to do than just that.
Here are some of the issues you'll run into:
Try out these two statements:
select cast('½' as varchar(10) character set ISO8859_1)
from rdb$database
select cast('½' as varchar(10) character set UTF8)
from rdb$database
The first one works, and the second one does not.
In the end simply altering the field will expose the four issues above however you won't know they exist until you come across them, which in a complicated database may not be until a production level user runs into them. Meanwhile copying the data will yield more work for yourself but will enable you to correctly handle all the items above.
Two more things to note:
If you copy the data you'll get an error for #4. Rather you should scrub this data as needed and do this with an external application that can convert these values correctly. ASCII 171 = UTF 189 = 1/2 character.
Any application code that executes statements against these fields can still violate the 64KB rule for issue #3. You need to search all larger fields or statements at a minimum to ensure you are not hitting this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With