MCPcopy Create free account
hub / github.com/SeanDragon/protools / toDBC

Method toDBC

common/src/main/java/pro/tools/data/text/ToolStr.java:292–307  ·  view source on GitHub ↗

转化为半角字符 @param s 待转字符串 @return 半角字符串

(String s)

Source from the content-addressed store, hash-verified

290 * @return 半角字符串
291 */
292 public static String toDBC(String s) {
293 if (isEmpty(s)) {
294 return s;
295 }
296 char[] chars = s.toCharArray();
297 for (int i = 0, len = chars.length; i < len; i++) {
298 if (chars[i] == 12288) {
299 chars[i] = ' ';
300 } else if (65281 <= chars[i] && chars[i] <= 65374) {
301 chars[i] = (char) (chars[i] - 65248);
302 } else {
303 chars[i] = chars[i];
304 }
305 }
306 return new String(chars);
307 }
308
309 /**
310 * 转化为全角字符

Callers

nothing calls this directly

Calls 1

isEmptyMethod · 0.95

Tested by

no test coverage detected