Convert Firebird fields / domains from ISO8859_1 to UTF8

I did some research using Google, but could not find the right answer.

I have a Firebird database and I always use my own domains for my tables fields. All of these domains are defined using 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 now I changed my fields to “real” UTF8? Or does it stay inside ISO08859_1?

If I search on the internet, some say:

  • through a temporary field and copying all the data (a lot of work with large databases)

and others say:

  • just change the domain or data type of the field.

What is right? What could go wrong? We have many clients, and I want to convert the database using a script.

+4
source share
1 answer

Changing a field does not change any data inside this field. And that will cause a lot of problems for you along the line. The best way to do this is to copy the data, however you have more work than simple.

Here are some of the problems you will encounter:

  • Any stored procedures / triggers that use this field must be updated to use newer variables.
  • varchar (100) 100 ASCII, UTF 400 . , UTF 8191. , varchar char, , .
  • , varchar (100) ASCII UTF, , Firebird 64 . .
  • 127 ASCII, . : ½. 171 , , UTF8.

:

select cast('½' as varchar(10) character set ISO8859_1)
from rdb$database

select cast('½' as varchar(10) character set UTF8)
from rdb$database

, - .

, , , , , , . , .

:

  • , №4. , . ASCII 171 = UTF 189 = 1/2 .

  • , , - 64 №3. , , .

+1

Source: https://habr.com/ru/post/1533321/


All Articles