List of utility methods to do Char Create
String | toChar(int i) 0, 1, ..., 51 -> "A", "B", ..., "Z", "AA", "AB", ..., "AZ" String s = ""; if (i >= 0 && i < 26) { s = s + (char) ('A' + i); } else if (i >= 26 && i < 52) { s = "A" + (char) ('A' + i - 26); return s; |
char | toChar(int i) to Char if (i >= 0 && i < 26) return (char) (i + 'A'); else if (i >= 26 && i < 52) return (char) (i + 'a' - 26); else if (i >= 52 && i < 62) return (char) (i + '0' - 52); else throw new IllegalArgumentException("Unsupported char code [" + i + "]."); ... |
char | toChar(int var) to Char return (char) var; |
String | toChar(int[] arr) to Char StringBuffer sb = new StringBuffer(); for (int i = 0; i < arr.length; i++) { sb.append((char) arr[i]); return sb.toString(); |
String | toChar(int[] arr) to Char return toString(arr);
|
char | toChar(Object obj) Get the char value of this object, only if the object is an instance of Character return (obj instanceof Character) ? ((Character) obj).charValue() : '\u0000'; |
char | toChar(Object value) to Char if (null == value) { throw new RuntimeException("Impossible to convert " + value + " from " + (null == value ? "unknown" : value.getClass().getName()) + " to " + char.class.getName()); if (value instanceof Character) { return ((Character) value).charValue(); if (value instanceof Number) { ... |
char | toChar(short o) to Char return (char) o; |
char | toChar(String chars) to Char String charsLower = chars.toLowerCase(); char highChar = charsLower.length() > 1 ? charsLower.charAt(0) : '0'; char lowChar = charsLower.length() > 1 ? charsLower.charAt(1) : charsLower.charAt(0); int byteHigh = Character.isDigit(highChar) ? highChar - '0' : highChar - 'a' + 10; int byteLow = Character.isDigit(lowChar) ? lowChar - '0' : lowChar - 'a' + 10; return (char) (((byteHigh << 4) | byteLow) & 0xff); |
char | toChar(String delimiter) to Char if (delimiter.length() == 1) { return delimiter.charAt(0); } else if (delimiter.toLowerCase().startsWith("0x") && delimiter.length() == 4) { return (char) Integer.parseInt(delimiter.substring(2), 16); } else if (delimiter.toLowerCase().startsWith("\\0") && delimiter.length() == 4) { return (char) Integer.parseInt(delimiter.substring(2)); } else if (Character.isDigit(delimiter.charAt(0))) { return (char) Integer.valueOf(delimiter).intValue(); ... |