1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

Merge remote-tracking branch 'up/master' into endpoints

This commit is contained in:
theonefx
2021-01-29 23:32:37 +08:00
2 changed files with 14 additions and 4 deletions

View File

@@ -33,16 +33,26 @@ public final class NacosConfigUtils {
StringBuilder sb = new StringBuilder();
char[] chars = configValue.toCharArray();
for (char aChar : chars) {
if (isChinese(aChar)) {
sb.append("\\u").append(Integer.toHexString(aChar));
if (isBaseLetter(aChar)) {
sb.append(aChar);
}
else {
sb.append(aChar);
sb.append(String.format("\\u%04x", (int) aChar));
}
}
return sb.toString();
}
/**
* char is base latin or whitespace?
* @param ch a character
* @return true or false
*/
public static boolean isBaseLetter(char ch) {
Character.UnicodeBlock ub = Character.UnicodeBlock.of(ch);
return ub == Character.UnicodeBlock.BASIC_LATIN || Character.isWhitespace(ch);
}
/**
* char is chinese?
* @param c a character