Page 1 of 1

UniDAC + Lazarus + MSSQL + Polish characters

Posted: Tue 25 Jul 2017 17:02
by Lazarusowski
I am using: WIN10 64 (15063); Lazarus 1.6.4 (32bit); UniDAC 7.0.2

Microsoft SQL Server Express (64-bit) v.12.0.4232.0
Server Collation Polish_CI_AS

In the database column [gr_Name] is varchar(50)

Code: Select all

    [gr_Name]
    ----------
    AŁŁA
    BĄBELKI
    GOŁĄBKI
    SŁODKI
    ZŁOMZŁOMOWY
My query: UniQuery1.SQL.ADD('SELECT LEN([gr_Name]) as number_char, [gr_Name] ');

If ZConnection1.SpecificOptions.Values['Provider'] := 'prAuto'
then I get in the grid:

Code: Select all

           number_char              [gr_Name]
  ---------------------------------------------------------
              4                       A
              7                       B?BELKI   
              7                       GO?BKI
              6                       S?ODKI 
              11                      Z?OMZ?OMOWY
No Polish characters and missing characters.

if ZConnection1.SpecificOptions.Values['Provider'] := 'prDirect'
then I get in the grid:

Code: Select all

           number_char              [gr_Name]
  ---------------------------------------------------------
              4                       AŁ
              7                       BĄBELK   
              7                       GOŁĄB
              6                       SŁODK 
              11                      ZŁOMZŁOMO 
Now they are Polish characters but words are too short.

What to do to get all the words along with the Polish characters ?

Re: UniDAC + Lazarus + MSSQL + Polish characters

Posted: Thu 27 Jul 2017 05:22
by azyk
The specified problem may occur if the server returns string data in Polish charset, and the client uses English charset. For correct displaying of national characters, use SQL Server data types that support Unicode, i.e. instead of char/varchar/text, use nchar/nvarchar/ntext.

Re: UniDAC + Lazarus + MSSQL + Polish characters

Posted: Thu 27 Jul 2017 08:23
by Lazarusowski
Thank you for the quick reply.
What do you mean "client" ? It's about UniDAC connection or GRID ?
I can not use nchar/nvarchar/ntext because it's not my base. External database of another program.

In SQL Server Management Studio it is ok.
Why, if I set "Provider= prDirec", he cuts off the words?

There is another solution?
You have other ideas?

Re: UniDAC + Lazarus + MSSQL + Polish characters

Posted: Thu 27 Jul 2017 11:52
by azyk
Thanks for the information.

We reproduced the issue of truncating string values ​​in the Direct mode for Lazarus. At the moment, we are investigating the issue and as soon as we have results, we will inform you.

The word "Client" in this context means a client-side application.

To solve the issue of displaying national characters, you can map varchar to WideString using UniDAC Data Type Maping. For example, you can add a mapping rule for TUniConnection at the design (component editor, Data Type Maping tab), or in run-time:

Code: Select all

UniConnection.DataTypeMap.AddDBTypeRule (msVarchar, ftWideString);
Note: to use the msVarchar constant, add the MSDataTypeMapUni unit to the uses section.

Refer to our online documentation to get more information about Data Type Mapping: https://www.devart.com/unidac/docs/inde ... apping.htm .

Re: UniDAC + Lazarus + MSSQL + Polish characters

Posted: Thu 27 Jul 2017 14:48
by Lazarusowski
Thank you for the quick reply.

I am using Data Type Mapping.
It works!
Now, everything is ok.

Thank you for your help.