FIBPlus versions 6.0 upwards do support UNICODE. Earlier FIBPlus versions did not have this feature, that's why it was NOT possible at all to use charset of the UNICODE_FSS connection and no details about the database contents were provided . This article is aimed at explaining how to work with UNICODE correctly.


If you declare, i.e.
CREATE TABLE NEW_TABLE (
ID INTEGER NOT NULL,
NAME_1251 VARCHAR(10) CHARACTER SET WIN1251,
NAME_1252 VARCHAR(10) CHARACTER SET WIN1252,
NAME_UNICODE VARCHAR(10) CHARACTER SET UNICODE_FSS
);

the server will keep the data of the field NAME_1251 in the charset WIN1251, NAME_1252 in WIN1252 and NAME_UNICODE in UNICODE_FSS respectively.

You may set the connection charset in connection parameters. I.e.on setting charset to WIN1251, the client reports to the server that it can work only with charset WIN1251. In respond to this after getting any query from the above-mentioned table, the server tries to recode the data into charset WIN1251 and show the result in this charset. If some string field cannot be recoded, the client will receive an error report from the the server on fetching a record. In other words, the server usually responds to the connection in the charset defined in connection parameters. Getting modification queries, it also considers them to be in the connection charset. Then the server tries to recode the data into a certain field charset.

Now we will show what happens to connection with UNICODE_FSS. The client receives data in UNICODE_FSS. The data must be sent back also in UNICODE_FSS, because the connection parameter is set to UNICODE_FSS. This means that for such a connection you should recode the data into WideString after receiving them (otherwise they will be shown incorrectly). Before sending the data back you should recode them into UNICODE_FSS, that is into UTF8String.

In case of charset NONE the server recodes and controls nothing. Having fields of the UNICODE_FSS type you should do necessary recoding yourself. In case of other field types you should not allow, for example, WIN1252 symbols to appear in the WIN1251 field. You may use some client tools for this purpose. If WIN1252 appear in the WIN1251 field, the data being read will be interpreted incorrectly. Thus you may easily work with a multi lingual database and keep the data in any language in UNICODE_FSS columns. Any string may have symbols in English, Russian, Chinese and any other languages at once. You should only remember that such a string may be read only in charset NONE and UNICODE_FSS. In charset NONE the server recodes nothing, so there are no error messages. In case of UNICODE_FSS the connection charset is similar to the field charset, thus the string is also received with no changes and recoded at the client.

You should remember about two issues:

  1. No recoding is ever done for charset OCTETS and NONE, so you shouldn't work with these fields in any connection charset.
  2. InterBase and Firebird show an error "Arithmetic overflow or string truncate" if you read fields in charsets, other than UNICODE, OCTETS or NONE, in UNICODE. This happens because the server is "puzzled". On one hand it has a declared field length, on the other hand, it responds to the client in UNICODE, i.e, the length of the response in bytes may be more than that of the declared field. For instanse filling in the WIN1251 field with maximum data and then using UNICODE connection, you may get this error.

There are two ways of from this situation. The first one implies asking Firebird/InterBase developers to fix this bug. The second suggests writing queries with forced CAST, which provides longer length for each such field.

FIBPlus versions 5.3 downwards don't know about such peculiarities, so they cannot do such field recoding. FIBPlus 6.0 and its next versions correctly work with UNICODE.

Note: Standard components cannot work with UNICODE strings! For this purpose use only special controls with defined UNICODE charsets, they will show UNICODE strings correctly after the above-mentioned recoding.


Preview text: 

FIBPlus versions 6.0 upwards do support UNICODE. Earlier FIBPlus versions did not have this feature, that's why it was NOT possible at all to use charset of the UNICODE_FSS connection and no details about the database contents were provided . This article is aimed at explaining how to work with UNICODE correctly.


Prices in Euro:

235 (1 copy)
1250 (unlimited)

Volume discounts are available...

Navigation



"FIBPlus is a great choice if you're going to work with InterBase and/or Firebird. The components let you easily use all the features of both databases in your applications...FIBPlus will make your InterBase and Firebird development easier than ever before...". Read the full story. >>

Bill Todd, president of The Database Group, Inc., a contributing editor to Delphi Informant Magazine, and a member of Team B
FOR CUSTOMERS
Download full versions and updates in your Personal Area