NSURL is missing IDN support

Number:rdar://29948279 Date Originated:10-Jan-2017 05:05 PM
Status:Open Resolved:
Product:Developer Tools Product Version:10.2
Classification:Enhancement Reproducible:Always
NSURL and NSURLComponents don’t support internationalized domains. WebKit already supports them, and from what I’ve been able to find it uses libicucore, which is available to developers, but some headers are stripped for some reason.

Steps to Reproduce:

Run this code

print(URL(string: "http://❤️❤️❤️.ws"))
var components = URLComponents()
components.scheme = "http"
components.host = "❤️❤️❤️.ws"

Expected Results:

It should print http://xn--qeiaa.ws/ twice

Actual Results:

The first one prints nil as it fails to create the NSURL.
The NSURLComponents one uses percent-escaping for the host, which seems to work in WebKit, but loads a different site when used with NSURLSession


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!