<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 12 May 2017, at 00:05, Tony Parker <<a href="mailto:anthony.parker@apple.com" class="">anthony.parker@apple.com</a>> wrote:</div><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""><blockquote type="cite" class=""><div class="">On May 10, 2017, at 4:19 AM, Andrey Fidrya via swift-corelibs-dev <<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">Hi All,</div><div class=""><br class=""></div><div class="">Btw, when migrating from NSString's methods to URL I've noticed</div><div class="">that they work a bit differently: URL's methods convert strings</div><div class="">from NFC to NFD (decomposed) unicode form which is demonstrated</div><div class="">by the example below.</div><div class=""><br class=""></div><div class="">I had to additionally call .<span class="" style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;">precomposedStringWithCanonicalMapping</span></div><div class="">on resulting string to convert it back to NFC form.</div><div class=""><br class=""></div><div class="">This was very surprising as it wasn't mentioned anywhere in docs</div><div class="">and has broken non-english filename support in app.</div></div></div></blockquote><div class=""><br class=""></div>Out of curiosity, can you explain how this breaks your non-english filename support? What OS and filesystem are you using?</div></div></blockquote><div><br class=""></div><div><div>OS X, HFS+. The app reconstructed account names from filenames by dropping file extensions. The filename was converted to NFC form once then NSString's methods were used for manipulating the filename. These methods weren't denormalizing the string. After switching to URL the resulting account names started triggering warnings about invalid characters in them ('й' should have been a valid character, but after denormalizing it was no longer found).</div><div class=""><br class=""></div></div><div>- Andrey</div><br class=""><blockquote type="cite" class=""><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">- Tony</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">Is this expected behavior or a bug?</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;">//let source = "/my_file.txt"</span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>source =<span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(209, 47, 27);">"/мой_файл.txt"</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures;">// problematic is letter 'й'</span></div><div class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>disallowedCharacters =<span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">CharacterSet</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(charactersIn:<span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">source</span><span class="" style="font-variant-ligatures: no-common-ligatures;">).</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">inverted</span></div><div class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></div><div class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">do</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>{</span></div><div class="" style="margin: 0px; line-height: normal; color: rgb(209, 47, 27);"><span class="" style="font-variant-ligatures: no-common-ligatures;"> <span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);">print</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(</span><span class="" style="font-variant-ligatures: no-common-ligatures;">"--- NSString:"</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)</span></div><div class="" style="margin: 0px; line-height: normal; color: rgb(112, 61, 170);"><span class="" style="font-variant-ligatures: no-common-ligatures;"> <span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>result = (</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">source</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">as</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures;">NSString</span><span class="" style="font-variant-ligatures: no-common-ligatures;">).</span><span class="" style="font-variant-ligatures: no-common-ligatures;">deletingPathExtension</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">as</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures;">String</span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"> <span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);">print</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(result)</span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"> <span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);">print</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(result.</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);">rangeOfCharacter</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(from:<span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">disallowedCharacters</span><span class="" style="font-variant-ligatures: no-common-ligatures;">))</span></div><div class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div><div class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">do</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>{</span></div><div class="" style="margin: 0px; line-height: normal; color: rgb(209, 47, 27);"><span class="" style="font-variant-ligatures: no-common-ligatures;"> <span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);">print</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(</span><span class="" style="font-variant-ligatures: no-common-ligatures;">"--- String + URL:"</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)</span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"> <span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>result =<span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">URL</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(fileURLWithPath:<span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">source</span><span class="" style="font-variant-ligatures: no-common-ligatures;">).</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);">deletingPathExtension</span><span class="" style="font-variant-ligatures: no-common-ligatures;">().</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">path</span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"> <span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);">print</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(result)</span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"> <span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);">print</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(result.</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);">rangeOfCharacter</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(from:<span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">disallowedCharacters</span><span class="" style="font-variant-ligatures: no-common-ligatures;">))</span></div><div class="" style="margin: 0px; line-height: normal; color: rgb(112, 61, 170);"><span class="" style="font-variant-ligatures: no-common-ligatures;"> <span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);">print</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(result.</span><span class="" style="font-variant-ligatures: no-common-ligatures;">precomposedStringWithCanonicalMapping</span><span class="" style="font-variant-ligatures: no-common-ligatures;">.</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);">rangeOfCharacter</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(from:<span class="Apple-converted-space"> </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">disallowedCharacters</span><span class="" style="font-variant-ligatures: no-common-ligatures;">))</span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div></div></div></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">--- Output:</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><b class="">--- NSString:</b></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><b class="">/мой_файл</b></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><b class="">nil</b></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><b class="">--- String + URL:</b></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><b class="">/мой_файл</b></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><b class="">Optional(Range(Swift.String.CharacterView.Index(_base: Swift.String.UnicodeScalarView.Index(_position: 3), _countUTF16: 2)..<Swift.String.CharacterView.Index(_base: Swift.String.UnicodeScalarView.Index(_position: 4), _countUTF16: 1)))</b></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><b class="">nil</b></span></div></div><div class=""><br class=""></div><div class=""><br class=""></div></span></div><div class=""><div class="">Regards,</div>Andrey</div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 10 May 2017, at 12:45, Eric Blachère via swift-corelibs-dev <<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Thanks for the answer ! It seems a bit weird from them to advocate using NSString methods in the unavailability comment. I would rather use URL when I can even if the conversions are a bit tedious ^^<div class=""><br class=""></div><div class="">Thanks a lot,</div><div class="">Eric</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">2017-05-10 10:52 GMT+02:00 Brent Royal-Gordon<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:brent@architechies.com" target="_blank" class="">brent@architechies.com</a>></span>:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><span class="">> On May 8, 2017, at 9:39 AM, Eric Blachère via swift-corelibs-dev <<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>> wrote:<br class="">><br class="">> I was just wondering if there are plans to bring NSString functions manipulating paths into the native String class. (such as lastPathComponent, pathComponents etc...)<br class="">> Because even if we can always make an extension of String to easily cast it into NSString, it's still a bit of a shame to have to do it ;)<br class=""><br class=""></span>Unfortunately, it seems like the decision not to include these methods on String was quite deliberate.<br class=""><br class="">Here's the revision where that happened: <<a href="https://github.com/apple/swift/commit/1f2390f1c75be65f57f189247bfe4f9b2fc11e3b#diff-d38f60064c3752f096c043e756d8f201R925" rel="noreferrer" target="_blank" class="">https://github.com/apple/<wbr class="">swift/commit/<wbr class="">1f2390f1c75be65f57f189247bfe4f<wbr class="">9b2fc11e3b#diff-<wbr class="">d38f60064c3752f096c043e756d8f2<wbr class="">01R925</a>> As you can see, they had that working and chose to disable it, presumably because they want you to manipulate paths through `URL`. (I wish the radar referenced in the commit message were public, but alas, it's not.)<br class=""><span class="HOEnZb"><font color="#888888" class=""><br class="">--<br class="">Brent Royal-Gordon<br class="">Architechies<br class=""><br class=""></font></span></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-corelibs-dev mailing list<br class=""><a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-corelibs-dev" class="">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev</a><br class=""></div></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-corelibs-dev mailing list<br class=""><a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-corelibs-dev" class="">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev</a></div></blockquote></div></div></blockquote></div><br class=""></body></html>