add PunyCode

This commit is contained in:
Looly
2020-12-01 11:55:39 +08:00
parent c99b48a4c4
commit 8761c24e02
2 changed files with 94 additions and 34 deletions

View File

@@ -0,0 +1,18 @@
package cn.hutool.core.codec;
import org.junit.Assert;
import org.junit.Test;
public class PunyCodeTest {
@Test
public void encodeDecodeTest(){
String text = "Hutool编码器";
String strPunyCode = PunyCode.encode(text);
Assert.assertEquals("Hutool-ux9js33tgln", strPunyCode);
String decode = PunyCode.decode("Hutool-ux9js33tgln");
Assert.assertEquals(text, decode);
decode = PunyCode.decode("xn--Hutool-ux9js33tgln");
Assert.assertEquals(text, decode);
}
}