#1 2017-11-11 00:08:57

camu72
Member
From: Salta - Argentina
Registered: 2015-07-12
Posts: 28

UTF8 encode and persistence layer

Considering this:

TmyRecord = class(TSQLRecord).
TmyRecord instance work with rawUTF8 in runtime.
RestClient.Update(myRecord) save encoding UTF8 in persistence layer (Firebird DB in my case).
but...
I need Firebird DB in Ansi encode ( is a legacy proyect and is shared for reporting with other tecnologies )

My problem:
in FirebirdDB have a field (myField) with the value "cañon"
when retrive myRecord from the FirebirdDB, have a string "cañon" and not "cañon" wich is the correct string in UTF8.
when update myRecord.someOtherField, myField in FirebirdDB is filled with the value "".

1) Actually this is the secuence:
Firebird  : "cañon"
TSQLRecord: "cañon"
Firebird  : ""

2)I need this secuence:
Firebird  : "cañon"
TSQLRecord: "cañon"
Firebird  : "cañon"

I mean, there is a way of load or retrive values from de persistence layer, performing a convertion from Ansi To UTF8 in the TSQLRecord.crete(...), and get the second secuence?

For try, you can play with de SynFile in MainDemo.
1) Execute SynFile.exe
2) Put in same field the value "cañon"
3) Close SynFile.
4) Open SynFile.db3 with an external editor like "SQLite Administrator", and you can comprob that the value is "cañon"
This is the correct way...
5) now, edit and change "cañon" for "cañon"
6) Open SynFile.exe and see the value... only have "ca"

Thanks in advance...
Claudio.

Offline

#2 2017-11-11 08:12:00

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,237
Website

Re: UTF8 encode and persistence layer

It sounds like it you are making some confusion between encoding and text.
"cañon" is "cañon" in UTF-8.
You see "cañon" in a Sqlite3 editor only if the encoding is not correct when you write it...

Offline

#3 2017-11-11 10:26:24

camu72
Member
From: Salta - Argentina
Registered: 2015-07-12
Posts: 28

Re: UTF8 encode and persistence layer

Ok, Thanks ab...i Will Chek muy knowledge... But in SynFile.exe Is just compiled as it, and when open dB with SQLite administrator the Values Is wrong. Maybe the configuración of this editor Is wrong too. Will Chek this un my PC.

Offline

Board footer

Powered by FluxBB