List of utility methods to do Unicode Convert
String | zenkakuToHankaku(String value) zenkaku To Hankaku StringBuilder sb = new StringBuilder(value); for (int i = 0; i < sb.length(); i++) { int c = (int) sb.charAt(i); if ((c >= 0xFF10 && c <= 0xFF19) || (c >= 0xFF21 && c <= 0xFF3A) || (c >= 0xFF41 && c <= 0xFF5A)) { sb.setCharAt(i, (char) (c - 0xFEE0)); value = sb.toString(); return value; |
String | ToDBC(String input) To DBC if (input == null) { return ""; char[] c = input.toCharArray(); for (int i = 0; i < c.length; i++) { if (c[i] == 12288) { c[i] = (char) 32; continue; ... |
int | unicodePreservingIndex(String paramString, int paramInt) unicode Preserving Index if (paramInt > 0) { int i = paramString.length(); if (paramInt < i) { int j = paramInt + -1; if ((Character.isHighSurrogate(paramString.charAt(j))) && (Character.isLowSurrogate(paramString .charAt(paramInt)))) paramInt += -1; ... |
int | unicodePreservingIndex(String str, int index) Normalizes index such that it respects Unicode character boundaries in str . if (index > 0 && index < str.length()) { if (Character.isHighSurrogate(str.charAt(index - 1)) && Character.isLowSurrogate(str.charAt(index))) { return index - 1; return index; |
String | fullWidthToHalfWidth(String s) full Width To Half Width if (isEmpty(s)) { return s; char[] source = s.toCharArray(); for (int i = 0; i < source.length; i++) { if (source[i] == 12288) { source[i] = ' '; } else if (source[i] >= 65281 && source[i] <= 65374) { ... |
int | getEncodedSize(String value) get Encoded Size int result = 2 + 1; result += value.length() * (StringUtil.hasMultibyte(value) ? 2 : 1); return result; |
String | halfWidthToFullWidth(String s) half Width To Full Width if (isEmpty(s)) { return s; char[] source = s.toCharArray(); for (int i = 0; i < source.length; i++) { if (source[i] == ' ') { source[i] = (char) 12288; } else if (source[i] >= 33 && source[i] <= 126) { ... |
String | bytes2StringUNICODE(byte[] buf, int offset, int length, boolean bigEndian) format the byte[] to String in UNICODE encode if (buf != null && offset >= 0 && length >= 2 && buf.length >= (offset + length)) { int charsLen = length / 2; char[] cbuf = new char[charsLen]; for (int i = 0; i < charsLen; i++) { if (bigEndian) { cbuf[i] = (char) (((buf[i * 2 + offset] & 0xff) << 8 | (buf[i * 2 + 1 + offset] & 0xff)) & 0xffff); ... |
void | asciiToBCD(byte[] ascii_buf, int asc_offset, byte[] bcd_buf, int bcd_offset, int conv_len, int type) ascii To BCD int cnt; byte ch, ch1; int bcdOffset = bcd_offset; int asciiOffset = asc_offset; if (((conv_len & 0x01) > 0) && (type > 0)) { ch1 = 0; } else { ch1 = 0x55; ... |
byte[] | convertToUnicodeByteArray(String s) Converts the String to a UNICODE byte array. if (s == null) { return null; char c[] = s.toCharArray(); byte[] result = new byte[(c.length * 2) + 2]; for (int i = 0; i < c.length; i++) { result[(i * 2)] = (byte) (c[i] >> 8); result[((i * 2) + 1)] = (byte) c[i]; ... |