Recent

Author Topic: [SOLVED] SQLDB: UTF8 problem in Postgresql  (Read 1243 times)

mmelwin

  • New Member
  • *
  • Posts: 24
[SOLVED] SQLDB: UTF8 problem in Postgresql
« on: February 04, 2021, 09:53:04 pm »
I have set:
Code: Pascal  [Select][+][-]
  1.   SQL1.SQL.Clear;
  2.   SQL1.SQL.Add('SET CLIENT_ENCODING TO ''UTF8'';');
  3.   SQL1.ExecSQL;

But when moving values from one query to another. When a string contains national characters.
Code: Pascal  [Select][+][-]
  1. SQL1.SQL.Add('and m='''+Form1.SQLQueryTre['m']+'''');

I have an error:
Code: Pascal  [Select][+][-]
  1. Invalid byte sequence for encoding "UTF8"

What could be wrong?


« Last Edit: February 05, 2021, 08:20:01 am by mmelwin »

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: SQLDB: UTF8 problem in Postgresql
« Reply #1 on: February 04, 2021, 10:11:15 pm »
Hi!

Three apostrophe in the beginning and 4 in the end - that does not fit.

To get rid of the eyepowder '''' use #39!

Winni

lucamar

  • Hero Member
  • *****
  • Posts: 4217
Re: SQLDB: UTF8 problem in Postgresql
« Reply #2 on: February 04, 2021, 10:54:17 pm »
No, the apostrophes are all right as they are. The problem has to be in:
Form1.SQLQueryTre['m']
Check what it is returning (both as chars and as bytes); it's possible that at some point or other it's getting converted to some Windows/ISO code-page and it's not re-converting back to UTF-8.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

mmelwin

  • New Member
  • *
  • Posts: 24
Re: [SOLVED] SQLDB: UTF8 problem in Postgresql
« Reply #3 on: February 05, 2021, 08:45:16 am »
Everything was explained.
However, the problem was with another string.
Project is from delphi 2007 conversion.
Some *.pas files were in ANSI and not UTF8.
Everything works after conversion.

 

TinyPortal © 2005-2018