java.net.IDN seems to do the trick. From my Scala console:
scala> java.net.IDN.toUnicode("xn--9dbne9b.com")
res0: java.lang.String = שלום.com
Note that it works on the hostname, not the URL. So you'll have to strip/extract the http://
protocol first.
A quick glance at the documentation reveals it works in the opposite direction too. From above (my Unicode hostname in the variable res0
)
scala> java.net.IDN.toASCII(res0)
res3: java.lang.String = xn--9dbne9b.com