Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Unified Diff: url/android/java/src/org/chromium/url/IDNStringUtil.java

Issue 257673002: Make it possible to build url/ without ICU on android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Missed a spot Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « url/DEPS ('k') | url/android/url_jni_registrar.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/android/java/src/org/chromium/url/IDNStringUtil.java
diff --git a/url/android/java/src/org/chromium/url/IDNStringUtil.java b/url/android/java/src/org/chromium/url/IDNStringUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..32000fde5946fca3ec263943bb063ddf030b5917
--- /dev/null
+++ b/url/android/java/src/org/chromium/url/IDNStringUtil.java
@@ -0,0 +1,33 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.url;
+
+import org.chromium.base.CalledByNative;
+import org.chromium.base.JNINamespace;
+
+import java.net.IDN;
+
+/**
+ * This class is used to convert unicode IDN domain names to ASCII, when not
+ * building with ICU.
+ */
+@JNINamespace("url::android")
+public class IDNStringUtil {
+ /**
+ * Attempts to convert a Unicode string to an ASCII string using IDN rules.
+ * As of May 2014, the underlying Java function IDNA2003.
+ * @param src String to convert.
+ * @return: String containing only ASCII characters on success, null on
+ * failure.
+ */
+ @CalledByNative
+ private static String idnToASCII(String src) {
+ try {
+ return IDN.toASCII(src, IDN.USE_STD3_ASCII_RULES);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+}
« no previous file with comments | « url/DEPS ('k') | url/android/url_jni_registrar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698