Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: FireDAC get unknown string read Firebird (GB_2312) field in Ubuntu 16.04LTS



Permlink Replies: 1 - Last Post: Jan 9, 2018 11:10 PM Last Post By: Lajos Juhasz
rick wu

Posts: 3
Registered: 11/9/16
FireDAC get unknown string read Firebird (GB_2312) field in Ubuntu 16.04LTS
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 9, 2018 9:35 PM
My Firebird database use GB_2312 store string in some fields. I get unknown string when using TField.AsString. I tested read UTF8 string in the same Firebird server. Read string is OK.

I am using Delphi 10.2.2 + Ubuntu 16.04 LTS.

Anybody can help me?

Following is demo code:

    FDConnection := TFDConnection.Create(nil);
 
    with FDConnection do
    begin
      Params.Add('DriverID=FB');
      Params.Add('Port=3050');
      Params.Add('Protocol=TCPIP');
      Params.Add('CharacterSet=GB_2312');
 
      //Params.Add('CharacterSet=UTF8');
      //Params.Add('Database=/home/utndata/mytest.gdb');
 
      Params.Add('Database=/home/utndata/mytestansi.gdb');
      Params.Add('Server=192.168.2.23');
      Params.Add('User_Name=SYSDBA');
      Params.Add('Password=masterkey');
 
      FetchOptions.RowsetSize := -1;
 
      Connected := true;
    end;
 
    FDQuery := TFDQuery.Create(nil);
 
    FDQuery.Connection := FDConnection;
 
    sql := 'select * from student';
 
    FDQuery.sql.Add(sql);
 
    FDQuery.Open;
 
    FDQuery.First;
 
    while not FDQuery.Eof do
    begin
      CName := FDQuery.FieldByName('cname').AsVariant;
 
      Writeln('CNAME: ' + CName);//will print: CNAME: 2018???????????ֻ?ǹ???
 
      FDQuery.Next;
    end;


Edited by: rick wu on Jan 9, 2018 9:37 PM

Edited by: rick wu on Jan 9, 2018 9:41 PM
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: FireDAC get unknown string read Firebird (GB_2312) field in Ubuntu 16.04LTS [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 9, 2018 11:10 PM   in response to: rick wu in response to: rick wu
rick wu wrote:

My Firebird database use GB_2312 store string in some fields. I get
unknown string when using TField.AsString. I tested read UTF8 string
in the same Firebird server. Read string is OK.

I am using Delphi 10.2.2 + Ubuntu 16.04 LTS.

This is not a Firemonkey related question but a FireDAC one. You should
really ask this question in the FireDAC forum.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02