win1256 [SOLVED] lazarus / 16-Databases ---------------------------------------------------------------------- Mhmd60 · 2014-06-12 06:48 I have a problem using lazarus with mssql, my database codepage is windows 1256 when I connect to the database and start using the application I saw this text instead of the Arabic characters '??????????'. Any help please? ---------------------------------------------------------------------- luca · 2014-06-12 08:29 Hi. Try to use Code: [Select]AnsiToUTF8(qry.FieldByName('Fieldname').AsString) Regards Luca ---------------------------------------------------------------------- mangakissa · 2014-06-12 09:07 I understand the problem of Mhmd60. luca's option is a workaround, but doesn't work with database GUI components. ---------------------------------------------------------------------- taazz · 2014-06-12 09:22 Quote from: mangakissa on June 12, 2014, 11:07:43 amluca's option is a workaround, but doesn't work with database GUI components. It doesn't? How is that? ---------------------------------------------------------------------- Mhmd60 · 2014-06-12 09:34 Thank you Mr. Luca and Mr. mangakissa, but as Mr. mangakissa said it doesn't work. ---------------------------------------------------------------------- marcov · 2014-06-12 10:06 What is your windows codepage? The database can be codepage  1256, but that doesn't mean the default windows codepage is. ---------------------------------------------------------------------- Mhmd60 · 2014-06-12 11:20 Thank you Mr. marcov, my windows codepage is win1256 Arabic. ---------------------------------------------------------------------- Mike.Cornflake · 2014-06-12 11:22 Quote from: taazz on June 12, 2014, 11:22:35 amQuote from: mangakissa on June 12, 2014, 11:07:43 amluca's option is a workaround, but doesn't work with database GUI components. It doesn't? How is that? I assume you're asking "Why doesn't AnsiToUTF8(qry.FieldByName('Fieldname').AsString) work for the DB aware GUI controls?" Quick answer - because those controls populate their value directly from the dataset, there's no place that Luca's workaround can be applied. Well actually, that's not true. Moving away from your question @Taaz @Mhmd60  Try the following code... Code: [Select]...   TForm1 = Class(TForm)     Procedure DatasetOnGetText(Sender: TField; Var aText: Ansistring; DisplayText: Boolean);     Procedure InitialiseDataset;  .. Procedure TForm1.DatasetOnGetText(Sender: TField; Var aText: Ansistring;   DisplayText: Boolean); Begin   aText := AnsiToUTF8(Sender.AsString); End;  Procedure TForm1.InitialiseDataset; Var   i: Integer;   oField: TField; Begin   If Not Assigned(FDataset) Then     Exit;   For i := 0 To FDataset.FieldCount - 1 Do   Begin     oField := FDataset.Fields[i];     If oField.DataType =ftString Then       oField.OnGetText := @DatasetOnGetText;   End; End;    Then just find an appropriate place to call InitialiseDataset;.  Presumably just after your Dataset.Open; ---------------------------------------------------------------------- taazz · 2014-06-12 11:25 see there is a place for the workaround to be used after all. But my question was more generic a comment of it does not work or can't be used with data aware controls is to generic there I was only asking for more details in the same spirit of the post. ---------------------------------------------------------------------- LacaK · 2014-06-12 11:26 Quote from: Mhmd60 on June 12, 2014, 08:48:36 amI have a problem using lazarus with mssql, Which components do you use to connecto to MS SQL Server ? TMSSQLConnection or TODBCConnection or any others ? ---------------------------------------------------------------------- mangakissa · 2014-06-12 11:35 Quote from: taazzIt doesn't? How is that?It's exactly what I ment. Mike.Cornflake has a really nice workaround and still is. If you're a beginner and using not standard UTF8 Lazarus could be 'a pain in the ass'. I think this is a very old discussion ---------------------------------------------------------------------- Mike.Cornflake · 2014-06-12 11:38 Hmmm.  I've just noticed that Dataset.OnGetText uses Ansistring for DisplayText...   I'm not that familiar with Unicode issues but from what I understand, this is a potential issue. @Mhmd60:  If you do try my workaround, could you let us know if it worked or not? ---------------------------------------------------------------------- Mhmd60 · 2014-06-12 12:28 First of all, I would like to thank all of you who tried to help me solve my problem, Thank you very very much. sorry for not telling you that I used zeosdb, but when I converted to mssql connection the problem solved. You are very kind. Thank you again.