From 914463b4d8a3ece0adcc5c7a962b8a19efbd987c Mon Sep 17 00:00:00 2001 From: zhaoxinhu <759054522@qq.com> Date: Thu, 18 Aug 2022 08:58:05 +0800 Subject: [PATCH] =?UTF-8?q?punycode=E8=BD=AC=E7=A0=81=E5=AE=8C=E6=95=B4?= =?UTF-8?q?=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/hutool/core/codec/PunyCode.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/hutool-core/src/main/java/cn/hutool/core/codec/PunyCode.java b/hutool-core/src/main/java/cn/hutool/core/codec/PunyCode.java index c6474a4a0..5bca5f6b0 100644 --- a/hutool-core/src/main/java/cn/hutool/core/codec/PunyCode.java +++ b/hutool-core/src/main/java/cn/hutool/core/codec/PunyCode.java @@ -24,6 +24,35 @@ public class PunyCode { public static final String PUNY_CODE_PREFIX = "xn--"; + /** + * punycode转码域名 + * @param domain + * @return + * @throws UtilException + */ + private static String encodeDomain(String domain) throws UtilException{ + Assert.notNull(domain, "domain must not be null!"); + String[] split = domain.split("\\."); + StringBuilder outStringBuilder = new StringBuilder(); + for (String string: split) { + boolean encode = false; + for (int index=0; index