Jump to content
CarloM

TOpenDialog.FileName encoding problems on Mac OS

Recommended Posts

Hello,

When I use a OpenDialog.Filename on Mac OS and stores value in a SQlite varchar(255) column

no english chars like í, ó,... are converted to ? character.

 

Example: "Sin título.jpg" is converted to "Sin t?tulo.jpg" when stores to database.

 

If I invoke a showMessage(OpenDialog.Filename) it is ok.

but when I save:

 

DS.Edit;
DS.FieldByName('Nombre').AsString := ExtractFileName(OpenDialog.Filename);
DS.Post;

 

or if Assign to a AnsiString var then problem is the same

 

Regards

Share this post


Link to post
On 4/11/2019 at 3:53 AM, CarloM said:

When I use a OpenDialog.Filename on Mac OS and stores value in a SQlite varchar(255) column

no english chars like í, ó,... are converted to ? character.

As they should be.

On 4/11/2019 at 3:53 AM, CarloM said:

Example: "Sin título.jpg" is converted to "Sin t?tulo.jpg" when stores to database.

 

If I invoke a showMessage(OpenDialog.Filename) it is ok.

Makes sense, since you are saving to an ANSI database field, so you are invoking a lossy Unicode->ANSI conversion.

On 4/11/2019 at 3:53 AM, CarloM said:

but when I save:

 


DS.Edit;
DS.FieldByName('Nombre').AsString := ExtractFileName(OpenDialog.Filename);
DS.Post;

 

or if Assign to a AnsiString var then problem is the same

Because you are still invoking a conversion to ANSI.

 

Have you tried switching the database column to nvarchar, and using TField.AsWideString?

  • Like 1

Share this post


Link to post

Hi Remy,

 

I am use a SQLite database in UTF8 mode, I think that all was saved in UT8.

 

on Windows works well

 

Share this post


Link to post
59 minutes ago, CarloM said:

Hi Remy,

 

I am use a SQLite database in UTF8 mode, I think that all was saved in UT8.

 

on Windows works well

 

Are you using FireDAC? Then show us the connection settings 

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

×