Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Unicode in DBGrid is not displayed correctly (https://www.delphipraxis.net/215990-unicode-dbgrid-not-displayed-correctly.html)

WalkingAway 9. Okt 2024 06:37

Delphi-Version: 5

Unicode in DBGrid is not displayed correctly
 
Hi there!
I have very strange problem. Data from SQL server in Delphi Athens doesn't respect Unicode.

ClientDataSet1.FieldDefs[0].DataType is ftWideString

ShowMessage(TСlientDataSet1.FieldByName('Name').As String); //Shows correctly - "ÖФ"
ShowMessage(DataSource1.DataSet.FieldByName('Name' ).AsString); //Shows correctly - "ÖФ"

In DBGrid I see wrong chars. Where from this problem is?

THank you in advance.

haentschman 9. Okt 2024 07:07

AW: Unicode in DBGrid is not displayed correctly
 
Hi...8-)

Welcome. :dp:

There is a DelphiPraxis forum in English. Would that be better for you?
https://en.delphipraxis.net

himitsu 9. Okt 2024 07:33

AW: Unicode in DBGrid is not displayed correctly
 
Welchen Typ und Kodierung besitzt
* das Feld, in der Datenbank?
* die Tabelle?
* die Datenbank?

Welche Kodierung wird bei der Verbindung bzw. Übertragung verwendet?


Ich würde mal vermuten, dass es als UTF-8 gespeichert wurde, aber als ANSI übertragen wird,
wonach der Typ des TStringField es dann nicht besser macht.

WalkingAway 9. Okt 2024 08:24

AW: Unicode in DBGrid is not displayed correctly
 
Thank you
I have MSSQL 2008 database and table, column type - nvarchar(50)
Nothing is set to FD connection (I have tried StringFormat=Choose, no difference)
I can see in ClientDataset data properly (like this), column's type here isftWideString :
ShowMessage(TСlientDataSet1.FieldByName('Name').As String);
ShowMessage(DataSource1.DataSet.FieldByName('Name' ).AsString);
May be it is wrong assumption, but I guess at this point everything is OK (data in correct encoding).

But in DBGrid it is shown in wrong way.

Thanks.

Zoot 9. Okt 2024 08:39

AW: Unicode in DBGrid is not displayed correctly
 
Delphi 5 ?

WalkingAway 9. Okt 2024 08:46

AW: Unicode in DBGrid is not displayed correctly
 
Nein, Delphi 12 Athens.

himitsu 9. Okt 2024 09:24

AW: Unicode in DBGrid is not displayed correctly
 
Pssst, in einigen Unterforen könnte auffallen, dass man oben die Delphi-Version auswählen kann, wie z.B. hier, im ersten Post (innerhalb von 24 Stunden änderbar).

Oder alternativ dieses im Nutzerprofil angeben.
https://www.delphipraxis.net/profile.php?do=editprofile

WalkingAway 10. Okt 2024 07:00

AW: Unicode in DBGrid is not displayed correctly
 
Hi.
Found strange think - data itself ok
As soon as I change DBGrid's DEFAULT_CHARSET to something else - everrything shown as unicode / coirrectly.
Why so?
THanks.

himitsu 10. Okt 2024 09:02

AW: Unicode in DBGrid is not displayed correctly
 
Sollte dieses DEFAULT_CHARSET bei Unicode nicht eigentlich ignoriert werden? :gruebel:

Wobei, dachte solche Property wurden inzwischen ausgebaut? (irgendwas mit Charset/Codepage)


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:13 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz