Jump to content
Sign in to follow this  
dlucic

Delphi Datasnap Android unicode problem

Recommended Posts

 

I created a Datasnap server application that connects to the MSSQL database via the TFDConnection object, and then executes a specific SQL query via the TFDQuery object, the results of which are further forwarded via the TDataSnapProvider object. This is screenshot of that application 

 

image.png.2e2602afe3fc945b0f501aafe7f45d37.png

 

I created a simple client application that opens this query and displays the results in a ListBox. This is the code :

 

image.thumb.png.1f88bbba7beca46a95b3962ab8be035d.png

 

When I run application on Windows I get a correct result with Serbian letters as you can see in the image below

 

image.png.ac708105f2f4ed310ec2918c80feca98.png

 

But when U start the same application on Android, I have a problem with display of Serbian letters.

 

image.png.bea8c8b8d1f3d2b24a9d57886344571c.png

 

What is the problem?

 

Thanks

 

 

Share this post


Link to post

My guess is that the data in the database is written using codepage 1250. On Windows the program converts the field values from CP 1250 to UTF-16 while Android does not.

Share this post


Link to post
10 minutes ago, Lajos Juhász said:

My guess is that the data in the database is written using codepage 1250. On Windows the program converts the field values from CP 1250 to UTF-16 while Android does not.

 

You are right. What can I do now?

Share this post


Link to post

You can try to use a mapping rule on the Datasnap server to map AnsiString to WideString that should solve the problem.

Share this post


Link to post
25 minutes ago, Lajos Juhász said:

You can try to use a mapping rule on the Datasnap server to map AnsiString to WideString that should solve the problem.

Can you help me please. I dont know how and where to do that

Share this post


Link to post

You can set mapping rules on a connection or query. In both cases you would double click the component. Select the Option menu. Check the Ignore inherited rules, in the stringgrid set the mapping from dtAnsiString to dtWideString. This will required that you change the class from TStringField to TWideStringField for the fields.

Share this post


Link to post
1 hour ago, Lajos Juhász said:

You can set mapping rules on a connection or query. In both cases you would double click the component. Select the Option menu. Check the Ignore inherited rules, in the stringgrid set the mapping from dtAnsiString to dtWideString. This will required that you change the class from TStringField to TWideStringField for the fields.

Thank you so much

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×