1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.url;
7 import org.chromium.base.CalledByNative;
8 import org.chromium.base.JNINamespace;
13 * This class is used to convert unicode IDN domain names to ASCII, when not
16 @JNINamespace("url::android")
17 public class IDNStringUtil {
19 * Attempts to convert a Unicode string to an ASCII string using IDN rules.
20 * As of May 2014, the underlying Java function IDNA2003.
21 * @param src String to convert.
22 * @return: String containing only ASCII characters on success, null on
26 private static String idnToASCII(String src) {
28 return IDN.toASCII(src, IDN.USE_STD3_ASCII_RULES);
29 } catch (Exception e) {