From 6d9766effd89bd1fba9bf27aab7b32e803f8fdd6 Mon Sep 17 00:00:00 2001 From: duandazhi Date: Fri, 2 Apr 2021 13:24:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9char=20utils=20=E5=B8=A6?= =?UTF-8?q?=E5=9C=88=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=9A=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/hutool/core/util/CharUtil.java | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/hutool-core/src/main/java/cn/hutool/core/util/CharUtil.java b/hutool-core/src/main/java/cn/hutool/core/util/CharUtil.java index 820b3e736..079319e86 100644 --- a/hutool-core/src/main/java/cn/hutool/core/util/CharUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/util/CharUtil.java @@ -375,6 +375,22 @@ public class CharUtil { * 'a' -》 'ⓐ' * * + * 获取带圈数字 /封闭式字母数字 ,从1-20,超过1-20报错 + * 0 1 2 3 4 5 6 7 8 9 A B C D E F + * U+246x ① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩ ⑪ ⑫ ⑬ ⑭ ⑮ ⑯ + * U+247x ⑰ ⑱ ⑲ ⑳ ⑴ ⑵ ⑶ ⑷ ⑸ ⑹ ⑺ ⑻ ⑼ ⑽ ⑾ ⑿ + * U+248x ⒀ ⒁ ⒂ ⒃ ⒄ ⒅ ⒆ ⒇ ⒈ ⒉ ⒊ ⒋ ⒌ ⒍ ⒎ ⒏ + * U+249x ⒐ ⒑ ⒒ ⒓ ⒔ ⒕ ⒖ ⒗ ⒘ ⒙ ⒚ ⒛ ⒜ ⒝ ⒞ ⒟ + * U+24Ax ⒠ ⒡ ⒢ ⒣ ⒤ ⒥ ⒦ ⒧ ⒨ ⒩ ⒪ ⒫ ⒬ ⒭ ⒮ ⒯ + * U+24Bx ⒰ ⒱ ⒲ ⒳ ⒴ ⒵ Ⓐ Ⓑ Ⓒ Ⓓ Ⓔ Ⓕ Ⓖ Ⓗ Ⓘ Ⓙ + * U+24Cx Ⓚ Ⓛ Ⓜ Ⓝ Ⓞ Ⓟ Ⓠ Ⓡ Ⓢ Ⓣ Ⓤ Ⓥ Ⓦ Ⓧ Ⓨ Ⓩ + * U+24Dx ⓐ ⓑ ⓒ ⓓ ⓔ ⓕ ⓖ ⓗ ⓘ ⓙ ⓚ ⓛ ⓜ ⓝ ⓞ ⓟ + * U+24Ex ⓠ ⓡ ⓢ ⓣ ⓤ ⓥ ⓦ ⓧ ⓨ ⓩ ⓪ ⓫ ⓬ ⓭ ⓮ ⓯ + * U+24Fx ⓰ ⓱ ⓲ ⓳ ⓴ ⓵ ⓶ ⓷ ⓸ ⓹ ⓺ ⓻ ⓼ ⓽ ⓾ ⓿ + * @link Unicode_symbols https://en.wikipedia.org/wiki/List_of_Unicode_characters#Unicode_symbols + * @link Enclosed Alphanumerics https://en.wikipedia.org/wiki/Enclosed_Alphanumerics + * 有其他特殊的需求,可以到 维基百科 查找说明 + * * @param c 被转换的字符,如果字符不支持转换,返回原字符 * @return 转换后的字符 * @since 5.6.2 @@ -399,14 +415,15 @@ public class CharUtil { * 20 -》 '⑳' * * 也称作:封闭式字符,英文:Enclosed Alphanumerics - * 见: 维基百科wikipedia-Unicode_symbols https://en.wikipedia.org/wiki/List_of_Unicode_characters#Unicode_symbols - * 见: 维基百科wikipedia-Unicode字符列表 https://zh.wikipedia.org/wiki/Unicode%E5%AD%97%E7%AC%A6%E5%88%97%E8%A1%A8 - * 见: coolsymbol https://coolsymbol.com/ - * 见: 百度百科 https://baike.baidu.com/item/%E7%89%B9%E6%AE%8A%E5%AD%97%E7%AC%A6/112715?fr=aladdin - * + * @author dazer * @param number 被转换的数字 * @return 转换后的字符 * @since 5.6.2 + * + * @link 维基百科wikipedia-Unicode_symbols https://en.wikipedia.org/wiki/List_of_Unicode_characters#Unicode_symbols + * @link 维基百科wikipedia-Unicode字符列表 https://zh.wikipedia.org/wiki/Unicode%E5%AD%97%E7%AC%A6%E5%88%97%E8%A1%A8 + * @link coolsymbol https://coolsymbol.com/ + * @link 百度百科 https://baike.baidu.com/item/%E7%89%B9%E6%AE%8A%E5%AD%97%E7%AC%A6/112715?fr=aladdin */ public static char toCloseByNumber(int number){ if(number > 20){ @@ -414,4 +431,14 @@ public class CharUtil { } return (char) ('①' + number - 1); } + + /** + * 获取带圈字符 + * Enclosed Alphanumerics + * @since 5.6.3 + * @see CharUtil#toEnclosedAlphanumericsCircleByInt(int) + */ + public static char toEnclosedAlphanumericsCircleByInt(int number){ + return CharUtil.toCloseByNumber(number); + } }