add method

This commit is contained in:
Looly 2022-01-25 10:56:51 +08:00
parent 06db212f24
commit 0e78438658
2 changed files with 21 additions and 4 deletions

View File

@ -2,10 +2,12 @@
# 🚀Changelog
-------------------------------------------------------------------------------------------------------------
# 5.7.21 (2022-01-21)
# 5.7.21 (2022-01-25)
### 🐣新特性
* 【extra 】 增加jetbrick模板支持
* 【extra 】 EmojiUtil增加方法pr#519@Gitee
### 🐞Bug修复
* 【core 】 修复ChineseDate农历获取正月出现数组越界BUGissue#2112@Github

View File

@ -130,15 +130,30 @@ public class EmojiUtil {
}
/**
* 将字符串中的Unicode Emoji字符转换为HTML表现形式
* 将字符串中的Unicode Emoji字符转换为HTML表现形式Hex方式
* <p>
* 例如<code>👦🏿</code> 转换为 <code>&amp;#128102;</code>
* 例如<code>👦🏿</code> 转换为 <code>&amp;#x1f466;</code>
*
* @param str 包含Emoji Unicode字符的字符串
* @return 替换后的字符串
*/
public static String toHtml(String str) {
return EmojiParser.parseToHtmlHexadecimal(str);
return toHtml(str, true);
}
/**
* 将字符串中的Unicode Emoji字符转换为HTML表现形式例如
* <pre>
* 如果为hex形式<code>👦🏿</code> 转换为 <code>&amp;#x1f466;</code>
* 否则<code>👦🏿</code> 转换为 <code>&amp;#128102;</code>
* <pre></pre>
*
* @param str 包含Emoji Unicode字符的字符串
* @return 替换后的字符串
*/
public static String toHtml(String str, boolean isHex) {
return isHex ? EmojiParser.parseToHtmlHexadecimal(str) :
EmojiParser.parseToHtmlDecimal(str);
}
/**