Java 不支持 IRI?
Java doesn't support IRI?
示例代码:
java.net.URI.create("http://测试.com").getHost(); // return null
new java.net.URL("http://测试.com").getHost(); // return "测试.com"
- 实际:URI 不解析 IRI
- 预期:两者return“测试.com”
相关文件:
在javadoc of URI中提到支持:
other The Unicode characters that are not in the US-ASCII character set, are not control characters (according to the Character.isISOControl method), and are not space characters (according to the Character.isSpaceChar method) (Deviation from RFC 2396, which is limited to US-ASCII)
众所周知
every URL is a URI, abstractly speaking, but not every URI is a URL.
所以上面的行为似乎并不符合预期。
你是对的。 Java 目前不支持 IRI。
您找到的 RFE 表明在 Java 6 中尝试实施 IRI。出于兼容性原因已回滚:
The change integrated into Mustang b67 as part of CCC 6348622 causes incompatibility issue, i.e. 6380332. We need to reexamine the usage of the term 'registry-based' in java.net.URI specification and record the incompatibility issue.
Will rollback URI class to Tiger version for compatibility reason.
最近,David Fuchs 做了一些工作来分析问题并提出了一些原型代码,但这自 2019 年以来似乎没有进展:
示例代码:
java.net.URI.create("http://测试.com").getHost(); // return null
new java.net.URL("http://测试.com").getHost(); // return "测试.com"
- 实际:URI 不解析 IRI
- 预期:两者return“测试.com”
相关文件:
在javadoc of URI中提到支持:
other The Unicode characters that are not in the US-ASCII character set, are not control characters (according to the Character.isISOControl method), and are not space characters (according to the Character.isSpaceChar method) (Deviation from RFC 2396, which is limited to US-ASCII)
众所周知
every URL is a URI, abstractly speaking, but not every URI is a URL.
所以上面的行为似乎并不符合预期。
你是对的。 Java 目前不支持 IRI。
您找到的 RFE 表明在 Java 6 中尝试实施 IRI。出于兼容性原因已回滚:
The change integrated into Mustang b67 as part of CCC 6348622 causes incompatibility issue, i.e. 6380332. We need to reexamine the usage of the term 'registry-based' in java.net.URI specification and record the incompatibility issue.
Will rollback URI class to Tiger version for compatibility reason.
最近,David Fuchs 做了一些工作来分析问题并提出了一些原型代码,但这自 2019 年以来似乎没有进展: