Skip to content

Instantly share code, notes, and snippets.

@norio-nomura
Created March 25, 2017 08:10
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norio-nomura/c8a4addd659e1208df500a37da58536d to your computer and use it in GitHub Desktop.
Save norio-nomura/c8a4addd659e1208df500a37da58536d to your computer and use it in GitHub Desktop.
APFSでファイル名がUnicode正規化されないことを検証する
let filenames = [
"\u{30D1}\u{30D1}", // パパ
"\u{30CF}\u{309A}\u{30CF}\u{309A}", // パパ
]
let fm = FileManager.default
let baseURL = fm.urls(for: .documentDirectory, in: .userDomainMask)[0]
filenames.forEach { filename in
let url = baseURL.appendingPathComponent(filename)
let fd = fopen(url.path, "w")
fputs(url.path, fd)
fclose(fd)
}
let files = try! fm.contentsOfDirectory(atPath: baseURL.path)
let filenameAndEscaped = files.map {
($0,
$0.unicodeScalars.map({
"\\{\(String($0.value, radix: 16))}"
}).joined())
}
filenameAndEscaped.forEach { print($0) }
/*
iOS 10.3実機だと
("パパ", "\\{30cf}\\{309a}\\{30cf}\\{309a}")
("パパ", "\\{30d1}\\{30d1}")
iOS 10.3 Simulatorだと
("パパ", "\\{30cf}\\{309a}\\{30cf}\\{309a}")
になる
*/
@The1andONLYdave
Copy link

Hi,
i'm affected too with your bug https://openradar.appspot.com/31265273
Is there any way (prefered without XCode) to check which app or which app's file-store contain the files, so that i can backup again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment