Transfer of txt file from Mac to Windows of causes ??.jpg to become ??????.jpg

I store file names internally in Korean in a text file. I also store the textfile with a Korean name.
If I save within the file a name written in Korean with an extension such as .jpg and transfer it from Mac to Windows, then Windows (not XOJO) doesn’t do its usual transformations.
For instance, this of causes ??.jpg to become ???.jpg
This is especially annoying since it generates nilobjects.

Any suggestions on prevention (besides compression)?

Could you elaborate on this? Windows doesn’t ordinarily transform the contents of text files.

I had been blaming XOJO for years for these nilbojects. I decided to look at a file in NotePad after making sure I had the correct name on my Mac. The files are duplicates so names are identical. Windows hadn’t transformed the characters for anything that could be a file (jpg, mp3, etc).
I also had a similar problem when I restored a file backup, but that was a file name and not just inside of text.
Not sure how to explain it any more clearly.

If you inserted the file name on Windows its quite possibly in UTF16 encoding for that filename
And when you pull that out on the Mac if you do not define the encoding on the Mac then you are bound to get bizarre results
Exactly like this

You need to use DefineEncoding for incoming strings (coming for example from files, from a database, via a tcp socket, etc.).

And you can use ConvertEncoding on exporting strings (to files, to databases, via tcp sockets, etc.).

Why not post the code with which you save the file and especially the code with which you read the file?

Sorry for bringing this back up but I’m wondering if this could be a solution?
When I did a search on Windows 10 settings for encoding or utf, nothing showed.

Display a non-US-ASCII filename in File Download dialog box