Unsolved file name change to unix file with escaping
-
-
in the linux ls -l look %100 identical but its not.
That is precisely why you will see I suggested you use
ls -b
in all my examples, which I guess is how you spotted it.... -
@RahibeMeryem said in file name change to unix file with escaping:
I found the STUPiD problem or a bug:
one of my folder path include 'ü' . utf8 character with spaces.
the 'ü' is different between mac os x and linux . in the linux ls -l look %100 identical but its not.
so I create same folder name with linux 'ü' its working now.
suprise.
Ah, we went full circle, let me quote:
@jsulm said in file name change to unix file with escaping:
@JonB said in file name change to unix file with escaping:
So you're going to say all of these are bad practice under Windows
Using existing system directories with spaces is not bad practice. But using own directories/file names with spaces (or umlauts) is at least questionable. I try to avoid this.
-
@J-Hilk
For all we know he has no choice about directory spelling. E.g. if his user name contains an umlaut he types in, I would guess Linux creates his home directory based on this. Perhaps because this is "bad practice" we'd better tell Linux to change its ways.... Or, perhaps the user should change his real name to accommodate... -
@JonB said in file name change to unix file with escaping:
Or, perhaps the user should change his real name to accommodate...
yep, that's what I did at my old work place,
ü -> ue -
@J-Hilk a bit OT but touches the good/bad practice part: in my workplace we have around 20 nationalities using 4 or 5 different alphabets. All the names and surnames in the sysaccounts/paths are transliterated to English exactly to avoid problems like that.
-
This vicious bug is due to the fact that Mac file system uses a special variant of unicode called decomposed form (NFD)
see https://developer.apple.com/library/archive/qa/qa1235/_index.htmlHowever, you may need to convert to precomposed Unicode when you interact with other platforms.
For example, the following are all valid reasons why you might want to convert to precomposed Unicode:
-If you implement a network protocol which is defined to use precomposed Unicode.
-When creating a cross-platform file (or volume) whose specification dictates precomposed Unicode.
-If you incorporate a large body of cross-platform code into your application,
where that code is expecting precomposed Unicode.For the same reason, if you're using C/C++ libraries that deal with file paths, it's advisable to use the following method for converting QString to *char:
[filePath.toNSString() fileSystemRepresentation]; -
@SGaist said in file name change to unix file with escaping:
@KroMignon that's a shell shortcut so it may or may not work depending on what you are doing.
Using QStandardPaths would be better.Yes, tilde is a shell shortcut, so should only ever be used in immediate mode on the command line in shells that recognize it. Use anywhere else can and probably will fail to be interpreted properly.
-
@Kent-Dorfman
Hence @SGaist's comment that you would hardly ever want to construct aQFile("~...")
anything. The only times would be for path-splitting function calls (even then be careful, e.g. Qt will think it's a relative path when in effect it's actually absolute), or to convert directly to string for passing to an OS command. Any other operations like trying to open it will not address the intended file (e.g. https://stackoverflow.com/questions/2816499/why-cant-qfile-read-from-the-directory).