Recent

Author Topic: UTF8 encoding  (Read 8033 times)

balazsszekely

  • Guest
Re: UTF8 encoding
« Reply #15 on: April 26, 2018, 02:26:02 pm »
Lazarus Trunk/FPC 3.0.4, but with 1.8.2 should work just fine.
Can you check something for me, add a showmessage here:
Code: Pascal  [Select][+][-]
  1. //...
  2.               ftDateTime,
  3.               ftTime: ZQuery1.Fields[c].AsDateTime := datacell^.NumberValue;
  4.               ftString: begin //here
  5.                            ZQuery1.Fields[c].AsString := datacell^.UTF8StringValue;
  6.                            ShowMessage(datacell^.UTF8StringValue);
  7.                         end;
  8.             end;
  9. //...

What do you see when you press the import button?

flori

  • Full Member
  • ***
  • Posts: 196
Re: UTF8 encoding
« Reply #16 on: April 26, 2018, 02:31:42 pm »
msgbox show normal character

balazsszekely

  • Guest
Re: UTF8 encoding
« Reply #17 on: April 26, 2018, 02:36:02 pm »
OK. Then zeos is the culprit. What is your Zeos version, I use 7.1

PS: Can somebody please test the project from reply #11 ?

flori

  • Full Member
  • ***
  • Posts: 196
Re: UTF8 encoding
« Reply #18 on: April 26, 2018, 02:40:01 pm »
I use zeos 7.0

balazsszekely

  • Guest
Re: UTF8 encoding
« Reply #19 on: April 26, 2018, 02:42:09 pm »
You can run a few test with 7.1. it's worth a try.

flori

  • Full Member
  • ***
  • Posts: 196
Re: UTF8 encoding
« Reply #20 on: April 26, 2018, 02:42:32 pm »
sorry I use zeosdbo-7.2.4-stable.

can you send your version?

flori

  • Full Member
  • ***
  • Posts: 196

balazsszekely

  • Guest
Re: UTF8 encoding
« Reply #22 on: April 26, 2018, 02:44:32 pm »
You can install it via OPM(http://wiki.freepascal.org/Online_Package_Manager).  Just uninstall 7.2.4 before and rename the old directory just to be sure.
« Last Edit: April 26, 2018, 02:47:23 pm by GetMem »

flori

  • Full Member
  • ***
  • Posts: 196
Re: UTF8 encoding
« Reply #23 on: April 26, 2018, 03:09:30 pm »
Yes just work :) :) :)
THANK YOUUUU!!!!!!!!!!!!!
I am very grateful :) :)
I have a small program which used ZConnection 7.2.4. Just I installed 7.0. I can change just ZConnection or ZConnection and all ZQuery, etc? What is your opinion? I have to replace every component or just ZConnection?
Thank u.

balazsszekely

  • Guest
Re: UTF8 encoding
« Reply #24 on: April 26, 2018, 03:33:50 pm »
Quote
Yes just work :) :) :)
THANK YOUUUU!!!!!!!!!!!!!
Cool! I'm glad it works.

Quote
What is your opinion? I have to replace every component or just ZConnection?
If you can open/build your project, you don't have to replace anything.
« Last Edit: April 26, 2018, 03:37:02 pm by GetMem »

flori

  • Full Member
  • ***
  • Posts: 196
Re: UTF8 encoding
« Reply #25 on: April 28, 2018, 12:37:13 am »
@GetMem! HELP! :(

I changed IBXexpert charset UTF8. When I tried to import mixed characters I get this... Dynamic SQL ErrorSQL error code = -303 - string right truncation.
Im enclosing.
I set ZConnection this:
codepage=UTF8
controls_cp=CP_UTF8

.. and installed 7.1.1
Do u know why am I get this error...?
Thank you

balazsszekely

  • Guest
Re: UTF8 encoding
« Reply #26 on: April 28, 2018, 06:11:22 am »
Please read this: http://www.firebirdfaq.org/faq79/
Possible causes:
1. The field(varchar) is too short. You need to increase column size
2. You're mixing different character set. Work only with UTF8 on both sides

Thaddy

  • Hero Member
  • *****
  • Posts: 14393
  • Sensorship about opinions does not belong here.
Re: UTF8 encoding
« Reply #27 on: April 28, 2018, 11:25:30 am »
And
3. Because an UTF8char can be 4 times the size of a (Ansi)Char, the field must also be 4 times the size you may expect because of that.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Zoran

  • Hero Member
  • *****
  • Posts: 1831
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: UTF8 encoding
« Reply #28 on: April 28, 2018, 01:59:25 pm »
And
3. Because an UTF8char can be 4 times the size of a (Ansi)Char, the field must also be 4 times the size you may expect because of that.

In Firebird, if the field is declared with codepage utf8 (and it is automatically, if the default character set for the database was set to utf8 before the table creation), the actual size is adjusted behind the scene (to be 4 times declared size, actually), it is not something you need to worry about.

To be sure of that, execute this (replace the table name in the last line):

Code: SQL  [Select][+][-]
  1. SELECT rf.rdb$relation_name, rf.rdb$field_name, cs.rdb$character_set_name,
  2.   f.rdb$character_length, f.rdb$field_length, cs.rdb$bytes_per_character
  3. FROM rdb$fields f
  4. INNER JOIN rdb$relation_fields rf ON rf.rdb$field_source = f.rdb$field_name
  5. INNER JOIN rdb$character_sets cs ON cs.rdb$character_set_id = f.rdb$character_set_id
  6. WHERE rf.rdb$relation_name = 'TABLE1' /* replace with your table name */
  7.  

You will get a list of the varchar and char fields from the table you want.
Now, examine the results:
  - is rdb$character_set_name for all fields "UTF8"?
  - compare the values of rdb$character_length and rdb$field_length.

flori

  • Full Member
  • ***
  • Posts: 196
Re: UTF8 encoding
« Reply #29 on: May 02, 2018, 09:11:05 pm »
Im enclosing my fdb file. I set UTF8, but not working at special characters.
The special characters include GAZDALKODAS2 table.
« Last Edit: May 02, 2018, 09:15:23 pm by flori »

 

TinyPortal © 2005-2018