Surprise ! Another Encoding trouble

My window is nice now, and I use it to add a Contact. But look below:

The “Centre Médico-…” was added on May 31 (2025).
No code change since then: I only re-open that project today.

The text (Folder and .sqlite file names) was written in the Xojo window (DesktopTextFields)…

I found the difference in the code:

db_Contact_File_Name = TF_Name_db_File.Text.ConvertEncoding(Encodings.ASCII)

Once I removed the ConvertEncodings (not used to create the Folder), the error was removed.

I do not remember why I added ConvertEncodings to create the sqlite file (name), but I certainly had a good reason to add code.

Ideas ?

Xojo 2025r1.1
Sequoia 15.5
MBP13" M1

LBN: looking at the code, some lines below, I found some System.DebugLog and here’s what I found:

Yes: Avoid non-ASCII characters in file names…

Then I have to:
reject user setting names with no ASCII characters,
add a Property for the .sqlite file name,

I forgot why I do not do that:
the project creates a folder for the entity (association, corporation), and another one for the .sqlite file.

@Emile_Schwarz - does your app only run on macOS? If so, non-ascii characters should be fine. There are a few silly differences between macOS encoding and Xojo encoding but they can be solved with declares if you have problems.

It’s probably more important that you not allow these characters :/\

Next time you do something like this, make a code comment to yourself saying why you made this weird change. You’ll thank yourself later.

1 Like

Yes. I comment my code, but here this is missing.

My UI and code ask the user to type the name for the folder and a name for the database (I add .sqlite if missing).
But I set the encoding only for the .sqlite file. I cant recall nor think at a reason why. And that worked not so long ago.

I use the Folder Name in the project. The project is a specialized Contacts application, so names are needed to access to the different categories (specialized Associations and Businesses)
I do not opened the project in the last 30 days…
Regards

For having portable code there putting into the database then ConvertEncoding(Encodings.UTF8) might make sense.

Since you might get something else than utf8 from folderItem on Windows for example. While when storing it in the database then it makes sense to have it stabilized to known encoding.

Which is what your intent might have been, the choice of encoding was just poor.

So when taking names from folderitems and putting in DB then doing ConvertEncoding(Encodings.UTF8) is not bad idea and then when you read from the DB you do DefineEncoding(Encodings.UTF8) on it to put in a promise that you are reading UTF8 data.

In fact, I ask the user to give the Entity name (used to create the working folder for that entity) and the .sqlite name.
As fas as I can say, I wanted to avoid non ASCII characters in the .sqlite file name, and using ASCII Encodings apparenty worked in May, but no more in July (same machine).

My brain actually runs at 25% (probably), and that is bad too.

Thanks for all answers. I will skip for the moment this part and wait better time to resolve the potential trouble. (I commented the Encodings part).

Thanks All.

I looked at Xojo 2025 Release 1.1 release date and this shows the difference I get in file creation comes from there: not the same Xojo version. :frowning: