|
|
@@ -0,0 +1,30 @@
|
|
|
+package com.chuanghai.repair.utils;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Author: binguo
|
|
|
+ * @Date: 2022/9/1 星期四 9:55
|
|
|
+ * @Description: com.chuanghai.repair.utils
|
|
|
+ * @Version: 1.0
|
|
|
+ */
|
|
|
+public class UnicodeUtil {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Title: unicodeEncode
|
|
|
+ * @Description: unicode编码 将中文字符转换成Unicode字符
|
|
|
+ * @param string
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String unicodeEncode(String string) {
|
|
|
+ char[] utfBytes = string.toCharArray();
|
|
|
+ String unicodeBytes = "";
|
|
|
+ for (int i = 0; i < utfBytes.length; i++) {
|
|
|
+ String hexB = Integer.toHexString(utfBytes[i]);
|
|
|
+ if (hexB.length() <= 2) {
|
|
|
+ hexB = "00" + hexB;
|
|
|
+ }
|
|
|
+ unicodeBytes = unicodeBytes + "\\u" + hexB;
|
|
|
+ }
|
|
|
+ return unicodeBytes;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|