I use Linux(Ubuntu 13.04), PostgreSQL 9.2, Lazarus 1.0.12 and Unidac components 4.1.
I have some project without gui. Just console mode. When i build it with using module Interfaces and LCL all work fine and i see russian character. But if i build my application without that modules russian character displayed "?" .
Part of my simple test code:
Code: Select all
program appdaemon;
{$mode objfpc}{$H+}
{$DEFINE UNIX}
{$DEFINE UseCThreads}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes,
SysUtils,
CustApp,
apFuncs,
SYNCOBJS,
appManager,
dmServDBSimple,
//Interfaces,
enVarUtils,
other_funcs,
unidac10,
AnyClases,
variants,
baseunix,
libc,
enSessionStore,
erIniSettings,
erSQLClasses,
db;
...
var
lConnect: TerSQLConnection;
lQuery: TerSQLQuery;
lstr,lq: String;
i: Integer;
begin
try
Writeln('Start connecting to database...');
try
lConnect:= TerSQLConnection.Create(nil);
lQuery:= TerSQLQuery.Create(nil);
with lConnect do begin
Server := '192.168.1.202';
Database:= 'kbtm';
Username:= 'energy_dba';
Password:= 'dev_pass';
ProviderName:= 'postgresql';
SpecificOptions.Values['PostgreSQL.UseUnicode']:= 'True';
end;
lConnect.Connected:= True;
Writeln('Connecting to database is DONE');
Writeln('Select data from SREZ...');
lq:= 'select * from srez_type';
lQuery.Connection:= lConnect;
lQuery.SpecificOptions.Values['ExtendedFieldsInfo']:= 'true';
with lQuery do begin
SQL.Clear;
SQL.Add(lq);
Open;
end;
Writeln('Select data from SREZ is DONE. Recordscount - ' + IntToStr(lQuery.RecordCount));
lQuery.First;
while not lQuery.EOF do begin
lstr:= 'TYPE = ' + lQuery.FieldByName('IDNAME').AsWideString;
Writeln('str:' + lstr);
Writeln('str1:' + Utf8ToAnsi(UTF8Encode(lstr)));
lQuery.Next;
end;
except
on E: Exception do begin
Writeln('Error:' + e.Message);
end;
end;
finally
FreeAndNil(lQuery);
FreeAndNil(lConnect);
end;
P.S.
And another point. If i don't use this option ("UseUnicode") i receive clipped data but in right charset. Example: if charecter varying field length is 20 and length of the data in this field is 15 character then i see only 10 character.