ios - encoding information in filenames (iPhone/mac) -
ios - encoding information in filenames (iPhone/mac) -
i want encode short title in filenames. problem title contain character such colon or slash. there standard encoding typical/appropriate this?
edit: clarify, want encode title in such way encoded title used filename. or called percent escaping?
the way category on nsurl, utilize nsurl filename in particular directory. 1 time have nsurl, can fetch or save file using url after performing usual checks whether or not file exists , handling cases accordingly.
the relevant code snippet is:
+ (nsurl *)adnurlforfilename:(nsstring *)filename indirectory:(nssearchpathdirectory)searchdirectory { nsstring *percentescapedfilename = [filename stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]; nsfilemanager *filemanager = [[nsfilemanager alloc] init]; nsurl *urlfordirectory = [[filemanager urlsfordirectory:searchdirectory indomains:nsuserdomainmask] objectatindex:0]; homecoming [nsurl urlwithstring:percentescapedfilename relativetourl:urlfordirectory]; }
you can download total category code github - nsurl+adnfilehelpers
iphone ios osx encoding
Comments
Post a Comment