Bookstore

Recent

Author Topic: select a table by field with non English characters  (Read 561 times)

mrkwlee

  • New Member
  • *
  • Posts: 16
select a table by field with non English characters
« on: December 18, 2019, 10:25:42 am »
when  select * from mytable where myfield like '甲%' ,error of convert coding is thrown out to halt the program.
I have tried to use UTF8Encode but it still does not work.  If I replace '甲%' with any English  words like 'A%', it works.
database coding UTF8
My system is: win 10, Lazarus 2.0.6 , firebird 3, zeoslib 7,
I have google for 2 hours and got no answer.
Please help me.
« Last Edit: December 18, 2019, 10:39:17 am by mrkwlee »

tonyw

  • Full Member
  • ***
  • Posts: 155
    • MWA Software
Re: select a table by field with non English characters
« Reply #1 on: December 18, 2019, 12:24:03 pm »
Have you checked to ensure that the database connection is also using UTF8 encoding? This is separate from the default database character set.

It's probably also worth checking to ensure that the table column character set is also UTF8.


mrkwlee

  • New Member
  • *
  • Posts: 16
Re: select a table by field with non English characters
« Reply #2 on: December 19, 2019, 02:26:57 am »
thank you.
my connection code base is already UTF8.
I tried to set it to none yesterday, it works.
However, another problem come out is
var
  s: string;
begin
  s:='甲%';
  QZquery1.SQL.Text:='select * from mutable where desc like '
     +s;
....
end;
gives the same error as before.
I think the data type of s makes the problem. still not solved

winni

  • Hero Member
  • *****
  • Posts: 1115
Re: select a table by field with non English characters
« Reply #3 on: December 19, 2019, 02:55:20 am »
Hi!

First for debugging support:

U+7532

E794B2  // hex
15176882 //decimal
甲 // HTML

Belonging to the "monster" block  CJK Unified Ideographs.

Think about this:

If every component on the way from the database to the screen tries to decode UTF8 then it has to give some rubbish or exception.

Try to decode a a decoded utf8 char (string). It must crash somehow.
So check that only one component does a decode and the other only gives a rawstring to the next.

Winni





mrkwlee

  • New Member
  • *
  • Posts: 16
Re: select a table by field with non English characters
« Reply #4 on: December 19, 2019, 09:28:06 am »
thank you very much for your debug help.
It is solved by setting
 zconnection codepage to none
       and clientcodepage to cpUTF8.