Recent

Author Topic: Why a field length decreases after Post (Firebird)  (Read 3896 times)

finalist

  • Jr. Member
  • **
  • Posts: 99
Why a field length decreases after Post (Firebird)
« on: October 13, 2011, 05:11:32 am »
I have a table with two fields:
Code: [Select]
OBLAST VARCHAR(16)  by UTF8 Charset
ACTIVE VARCHAR(1)  by UTF8 Charset
I have a problem on Post of the field OBLAST VARCHAR(16). I fill it with Cyrillic Alphabet letters under TDBGrid component or TDBEdit component, when I post the TSQLQuery, it's length decreases suddenly if it's length is more than  8 letters.
Is there any solution ?
Thanks!

Lacak2

  • Guest
Re: Why a field length decreases after Post (Firebird)
« Reply #1 on: October 13, 2011, 07:10:47 am »
This is relative known problem (also in bug tracker is waiting bug report), where we still wait for some systematic solution.
Root of problem is in fact, that with UTF8 character data there is different character length than byte length.
And in record (field) buffer is allocated only character length bytes not  byte length.
(in UTF8 can 1 char be 1-4 bytes)

finalist

  • Jr. Member
  • **
  • Posts: 99
Re: Why a field length decreases after Post (Firebird)
« Reply #2 on: October 13, 2011, 07:54:07 pm »
Is there any different from UTF8 Charset, that supports Cyrillic alphabet, where 1 char to be 1 byte, may be if I use WIN1251 Charset ?
( Excuse me if this question is stupid )
Thanks !

Lacak2

  • Guest
Re: Why a field length decreases after Post (Firebird)
« Reply #3 on: October 14, 2011, 09:19:10 am »
May be, that in theory you can setup connection charset to Win1251 (so Interbase will send character data encoded in that format).

But then you will have problems with displaying such character data in db-aware controls (DBGrid etc.), because Lazarus expects/requires, that all strings are UTF-8 encoded.

So then you must hook into TField.OnGet/SetText and on the fly convert data from Win1251 to UTF8 and back.

For more info you can read:
http://bugs.freepascal.org/view.php?id=12206
http://bugs.freepascal.org/view.php?id=17376

finalist

  • Jr. Member
  • **
  • Posts: 99
Re: Why a field length decreases after Post (Firebird)
« Reply #4 on: October 14, 2011, 11:44:12 am »
First of bug-reports above is submited at 2008-09-22.
Second of bug-reports above is submited at 2010-09-09.
I don't think I can wait for some systematic solution.
This is a big problem for me.
Thanks!

 

TinyPortal © 2005-2018