public final class IDN extends Object
国际化域名是指在RFC 3490。RFC 3490定义了两个操作:toascii和tounicode。这2种操作使用Nameprep算法,这是Stringprep剖面,并Punycode算法将域名字符串来回。
上述转换过程的行为可以通过各种标志进行调整:
对国际化域名支持的安全性考虑是很重要的。例如,英文域名可以homographed -恶意拼错的非拉丁字母取代。Unicode Technical Report #36讨论支持IDN的安全问题以及可能的解决方案。应用程序负责在使用国际域名时采取适当的安全措施。
Modifier and Type | Field and Description |
---|---|
static int |
ALLOW_UNASSIGNED
允许指定的代码点处理标识
|
static int |
USE_STD3_ASCII_RULES
把对ASCII规则STD-3检查标志
|
Modifier and Type | Method and Description |
---|---|
static String |
toASCII(String input)
将一个字符串从Unicode字符的ASCII兼容编码(ACE),由
RFC 3490的toascii操作定义。
|
static String |
toASCII(String input, int flag)
将一个字符串从Unicode字符的ASCII兼容编码(ACE),由
RFC 3490的toascii操作定义。
|
static String |
toUnicode(String input)
翻译成ASCII兼容的编码为Unicode字符串(ACE),由
RFC 3490的tounicode操作定义。
|
static String |
toUnicode(String input, int flag)
翻译成ASCII兼容的编码为Unicode字符串(ACE),由
RFC 3490的tounicode操作定义。
|
public static final int ALLOW_UNASSIGNED
public static final int USE_STD3_ASCII_RULES
public static String toASCII(String input, int flag)
toascii操作失败。toascii失败如果任何步骤失败。如果toascii操作失败,会抛出IllegalArgumentException。在这种情况下,输入字符串不应该被使用在一个国际化的域名。
标签是域名的一个单独的部分。原toascii操作,RFC 3490中定义的,只有运行在一个单一的标签。这种方法可以处理两个标签和整个域名,假设标签在一个域名总是分开的点。下面的文字是公认的点:\ u002e(句号),\ u3002(表意的句号),\ uff0e(全角的句号),和uff61(半角表意的句号)。如果点作为标签分隔符,这种方法也改变了所有人\ u002e(句号)在翻译字符串输出。
input
-待处理的字符串
flag
过程标志;可以是0或任何逻辑的或可能的旗帜
String
IllegalArgumentException
-如果输入字符串不符合RFC 3490规范
public static String toASCII(String input)
这种方便的方法的工作原理,如果通过调用两个参数对应如下:
toASCII
(input, 0);
input
-待处理的字符串
String
IllegalArgumentException
-如果输入字符串不符合RFC 3490规范
public static String toUnicode(String input, int flag)
tounicode永不失败。在任何错误的情况下,输入字符串返回未修改的。
标签是域名的一个单独的部分。原tounicode操作,RFC 3490中定义的,只有运行在一个单一的标签。这种方法可以处理两个标签和整个域名,假设标签在一个域名总是分开的点。下面的文字是公认的点:\ u002e(句号),\ u3002(表意的句号),\ uff0e(全角的句号),和uff61(半角表意的句号)。
操作定义。input
-待处理的字符串
flag
过程标志;可以是0或任何逻辑的或可能的旗帜
String
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.