[Lazarus] Unicode text stored in database

Bogusław Brandys brandys at o2.pl
Fri May 15 12:18:25 CEST 2009


Graeme Geldenhuys wrote:
> Hi,
> 
> I briefly tried to store some unicode text (UTF-8) into a Firebird
> database and got some strange results in the Lazarus DB components.
> I'm not sure if the issue is in the Sqldb components or in the actual
> GUI DB components of LCL.
> 
> Anyway, can one define a VarChar() field with unicode text? I'm using
> Firebird 2.1.2
> 
> For example:
>     varchar(10) field definition
> 
>  - that would allow max. of 10 ansi characters
>  - what about UTF-8 characters?  Some chars can be anything from 1-4 bytes.
>  - does varchar() use bytes or characters? I believe it's bytes if I'm
> not mistaken.
> 
> If I can't use varchar(), then what? Char() :-( That would waste a lot
> of space, but if I have no alternative, then I guess it will have to
> do.
> 
> [...just did some more Googling...]
> 
>   http://www.firebirdsql.org/manual/migration-mssql-data-types.html
> I found a web page that mentions the migration of SQL Server to
> Firebird. It mentions NVarChar (sql server specific type for unicode
> text) to VARCHAR(x) CHARACTER SET UNICODE_FSS (firebird support). So I
> guess that's what I need to try. But which unicode format is firebird
> going to use? utf-8, utf-16, etc...
> 
> Has anybody successfully used Firebird DB to store Unicode text
> (preferably UTF-8 text)?  Anybody done that with Lazarus?
> 
> Regards,
>   - Graeme -
> 
> 

Hmm..that should be very easy with Firebird 2.1.2 though I've never 
tried yet. Lazarus is UTF-8 based, just set connection setting to UTF8 
and create database with UTF8 collation as default.

Then  in theory you could forget that it's all unicode.

Boguslaw






More information about the Lazarus mailing list