UseUnicod=True trigger WideString. Bug or feature?

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
kaffeburk
Posts: 210
Joined: Mon 29 Jan 2007 08:03

UseUnicod=True trigger WideString. Bug or feature?

Post by kaffeburk » Tue 19 May 2020 11:14

Hello Devart,

Found out that if i set a tUniconnection/Optins/UseUnicode = True the dataset will change from ftString to ftWidestring. This can be undone with datatypemapping in design or by the code:

Code: Select all

UniConnection2.DataTypeMap.Clear;
UniConnection2.DataTypeMap.AddDBTypeRule(221,ftString);
What is the reason for this? Can not a normal string handle unicode just fine?

Example code.
https://www.dropbox.com/s/trl22zp8zdvym ... e.rar?dl=0

ViktorV
Devart Team
Posts: 2853
Joined: Wed 30 Jul 2014 07:16

Re: UseUnicod=True trigger WideString. Bug or feature?

Post by ViktorV » Tue 19 May 2020 13:39

This behavior is correct https://www.devart.com/unidac/docs/using-mysql.htm. When the UseUnicode property is set to True, you can retrieve string data at the client side in Unicode encoding format, which enables you to work simultaneously with almost any language. All TStringField values will be converted to TWideStringField.
The UseUnicode option enables support for Unicode characters for the entire project, not just for creating fields of type TWideStringField. To create individual fields of type TStringField, you can use Data Type Mapping.

kaffeburk
Posts: 210
Joined: Mon 29 Jan 2007 08:03

Re: UseUnicod=True trigger WideString. Bug or feature?

Post by kaffeburk » Sun 24 May 2020 06:19

Powerful, nice done.

But in the documentation i think you forget to add info about the PgDataTypeMapUni unit. Without that unit the pgNumeric in your documentation wont work. Also some "pg" looks like they are missing, like pgVarchar.

We have quite a lot of clientdatasets where i don't want to change every fielddef from ftString to FtWIdechar and i need to programatically set the correct Data Type Mapping. By a lot of trial and error, like creating the Data Type Mapping in dfm and checking it i found that the code for varchar was 221. The syntax for mapping a Varchar to a ftString is also not documented. By more trial and error i did find it to be

Code: Select all

DataTypeMap.AddDBTypeRule(221,ftString);
I can also see that the lack of documentation about this was communicated five years ago.

viewtopic.php?t=31780

I find that a bit strange, it can hardly take more time to fix that then to read this. But it will take a lot more time for everybody to one and one invent the wheel over and over again.

oleg0k
Devart Team
Posts: 80
Joined: Wed 11 Mar 2020 08:28

Re: UseUnicod=True trigger WideString. Bug or feature?

Post by oleg0k » Tue 26 May 2020 13:23

Hello,
Thank you for the information, we'll describe that in more detail in future versions of UniDAC.
To map PostgreSQL character varying data type, you should use the constant pgCharacterVarying.

wbr, Oleg
Devart Team

Post Reply