0

I am making file manager app which will allows users to create and move files. I have an issue with moving files when file name or directory name contains special character, emoji or letter not from English alphabet. But I see that there are a lot of apps which allow to create folders and files with those characters in name and move them. Why I can not do that?

I move file to folder which name is emoji. For example this code does not create an error but in the destination folder file does not apper:

try FileManager.default.moveItem(atPath: atPath, toPath: toPath)

atPath:

/var/mobile/Containers/Data/Application/99F4B9F3-6EEB-4CA6-8BFF-73E761213C08/Documents/%E2%9D%A4%EF%B8%8F/201902180150250650.pdf

toPath:

/var/mobile/Containers/Data/Application/0702B04A-BC80-451F-BF84-A668D1990BBA/Documents/%F0%9F%8E%81/201902180148461430.pdf

%F0%9F%8E%81 is the name of the folder it's "gift emoji" but I used encoding to replace emoji:

 addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlPathAllowed)!

If i remove % from folder name - it's work, but after that I will not be able to convert it to original name

Marcuss
  • 13
  • 4
  • What do you mean by "If i remove % from folder name - it's work, but after that I will not be able to convert it to original name"? `URL(fileURLWithPath: "/%F0%9F%8E%81").path.removingPercentEncoding` returns `"/"` for me. – Leo Dabus Feb 18 '19 at 03:33
  • if folder name is "%F0%9F%8E%81" I can not move item into it, but if I set folder name without % - it will move files to folder. But I need to have name "%F0%9F%8E%81" to be able to display original folder name to the user – Marcuss Feb 18 '19 at 04:16
  • You should always display to the user the localized name from your file url resource. For example if you have a pictures folder in your Mac and your system is in Portuguese it should display "Photos". check this post https://stackoverflow.com/a/34772517/2303865 and https://developer.apple.com/documentation/foundation/urlresourcevalues/1779928-localizedname – Leo Dabus Feb 18 '19 at 04:18

0 Answers0