@Test public void testDumpString14() throws Throwable { byte[] b = new byte[5]; b[0] = (byte) 10; b[1] = (byte) -12; b[2] = (byte) 31; b[3] = (byte) 15; b[4] = (byte) 26; String result = ISOUtil.dumpString(b); assertEquals("{LF}\uFFF4[1F][0F][1A]", result, "result"); }
public static String dumpString(byte[] b) { StringBuilder d = new StringBuilder(b.length * 2); for (byte aB : b) { char c = (char) aB; if (Character.isISOControl(c)) { switch (c) { case '\r': d.append("{CR}"); break; case '\n': d.append("{LF}"); break; case '\000': d.append("{NULL}"); break; case '\001': d.append("{SOH}"); break; case '\002': d.append("{STX}"); break; case '\003': d.append("{ETX}"); break; case '\004': d.append("{EOT}"); break; case '\005': d.append("{ENQ}"); break; case '\006': d.append("{ACK}"); break; case '\007': d.append("{BEL}"); break; case '\020': d.append("{DLE}"); break; case '\025': d.append("{NAK}"); break; case '\026': d.append("{SYN}"); break; case '\034': d.append("{FS}"); break; case '\036': d.append("{RS}"); break; default: d.append('['); d.append(hexStrings[(int) aB & 0xFF]); d.append(']'); break; } } else d.append(c); } return d.toString(); }
ISOUtil { public static String dumpString(byte[] b) { StringBuilder d = new StringBuilder(b.length * 2); for (byte aB : b) { char c = (char) aB; if (Character.isISOControl(c)) { switch (c) { case '\r': d.append("{CR}"); break; case '\n': d.append("{LF}"); break; case '\000': d.append("{NULL}"); break; case '\001': d.append("{SOH}"); break; case '\002': d.append("{STX}"); break; case '\003': d.append("{ETX}"); break; case '\004': d.append("{EOT}"); break; case '\005': d.append("{ENQ}"); break; case '\006': d.append("{ACK}"); break; case '\007': d.append("{BEL}"); break; case '\020': d.append("{DLE}"); break; case '\025': d.append("{NAK}"); break; case '\026': d.append("{SYN}"); break; case '\034': d.append("{FS}"); break; case '\036': d.append("{RS}"); break; default: d.append('['); d.append(hexStrings[(int) aB & 0xFF]); d.append(']'); break; } } else d.append(c); } return d.toString(); } }
ISOUtil { public static String dumpString(byte[] b) { StringBuilder d = new StringBuilder(b.length * 2); for (byte aB : b) { char c = (char) aB; if (Character.isISOControl(c)) { switch (c) { case '\r': d.append("{CR}"); break; case '\n': d.append("{LF}"); break; case '\000': d.append("{NULL}"); break; case '\001': d.append("{SOH}"); break; case '\002': d.append("{STX}"); break; case '\003': d.append("{ETX}"); break; case '\004': d.append("{EOT}"); break; case '\005': d.append("{ENQ}"); break; case '\006': d.append("{ACK}"); break; case '\007': d.append("{BEL}"); break; case '\020': d.append("{DLE}"); break; case '\025': d.append("{NAK}"); break; case '\026': d.append("{SYN}"); break; case '\034': d.append("{FS}"); break; case '\036': d.append("{RS}"); break; default: d.append('['); d.append(hexStrings[(int) aB & 0xFF]); d.append(']'); break; } } else d.append(c); } return d.toString(); } ISOUtil(); }
ISOUtil { public static String dumpString(byte[] b) { StringBuilder d = new StringBuilder(b.length * 2); for (byte aB : b) { char c = (char) aB; if (Character.isISOControl(c)) { switch (c) { case '\r': d.append("{CR}"); break; case '\n': d.append("{LF}"); break; case '\000': d.append("{NULL}"); break; case '\001': d.append("{SOH}"); break; case '\002': d.append("{STX}"); break; case '\003': d.append("{ETX}"); break; case '\004': d.append("{EOT}"); break; case '\005': d.append("{ENQ}"); break; case '\006': d.append("{ACK}"); break; case '\007': d.append("{BEL}"); break; case '\020': d.append("{DLE}"); break; case '\025': d.append("{NAK}"); break; case '\026': d.append("{SYN}"); break; case '\034': d.append("{FS}"); break; case '\036': d.append("{RS}"); break; default: d.append('['); d.append(hexStrings[(int) aB & 0xFF]); d.append(']'); break; } } else d.append(c); } return d.toString(); } ISOUtil(); static String ebcdicToAscii(byte[] e); static String ebcdicToAscii(byte[] e, int offset, int len); static byte[] ebcdicToAsciiBytes(byte[] e); static byte[] ebcdicToAsciiBytes(byte[] e, int offset, int len); static byte[] asciiToEbcdic(String s); static byte[] asciiToEbcdic(byte[] a); static void asciiToEbcdic(String s, byte[] e, int offset); static void asciiToEbcdic(byte[] s, byte[] e, int offset); static String padleft(String s, int len, char c); static String padright(String s, int len, char c); static String trim(String s); static String zeropad(String s, int len); static String zeropad(long l, int len); static String strpad(String s, int len); static String zeropadRight(String s, int len); static byte[] str2bcd(String s, boolean padLeft, byte[] d, int offset); static byte[] str2hex(String s, boolean padLeft, byte[] d, int offset); static byte[] str2bcd(String s, boolean padLeft); static byte[] str2bcd(String s, boolean padLeft, byte fill); static String bcd2str(byte[] b, int offset,
                        int len, boolean padLeft); static String hex2str(byte[] b, int offset,
                                 int len, boolean padLeft); static String hexString(byte[] b); static String dumpString(byte[] b); static String hexString(byte[] b, int offset, int len); static String bitSet2String(BitSet b); static byte[] bitSet2byte(BitSet b); static byte[] bitSet2byte(BitSet b, int bytes); static int bitSet2Int(BitSet bs); static BitSet int2BitSet(int value); static BitSet int2BitSet(int value, int offset); static BitSet byte2BitSet(byte[] b, int offset, boolean bitZeroMeansExtended); static BitSet byte2BitSet(byte[] b, int offset, int maxBits); static BitSet byte2BitSet(BitSet bmap, byte[] b, int bitOffset); static BitSet hex2BitSet(byte[] b, int offset, boolean bitZeroMeansExtended); static BitSet hex2BitSet(byte[] b, int offset, int maxBits); static BitSet hex2BitSet(BitSet bmap, byte[] b, int bitOffset); static byte[] hex2byte(byte[] b, int offset, int len); static byte[] hex2byte(String s); static String byte2hex(byte[] bs); static byte[] int2byte(int value); static int byte2int(byte[] bytes); static String byte2hex(byte[] bs, int off, int length); static String formatDouble(double d, int len); static String formatAmount(long l, int len); static String normalize(String s, boolean canonical); static String stripUnicode(String s); static String normalize(String s); static String protect(String s, char mask); static String protect(String s); static int[] toIntArray(String s); static String[] toStringArray(String s); static byte[] xor(byte[] op1, byte[] op2); static String hexor(String op1, String op2); static byte[] trim(byte[] array, int length); static byte[] concat(byte[] array1, byte[] array2); static byte[] concat(byte[] array1, int beginIndex1, int length1, byte[] array2,
            int beginIndex2, int length2); static void sleep(long millis); static String zeroUnPad( String s ); static String blankUnPad( String s ); static String unPadRight(String s, char c); static String unPadLeft(String s, char c); static boolean isZero( String s ); static boolean isBlank( String s ); static boolean isAlphaNumeric( String s ); static boolean isNumeric( String s, int radix ); static byte[] bitSet2extendedByte( BitSet b ); static int parseInt(String s, int radix); static int parseInt(String s); static int parseInt(char[] cArray, int radix); static int parseInt(char[] cArray); static int parseInt(byte[] bArray, int radix); static int parseInt(byte[] bArray); static String hexdump(byte[] b); static String hexdump(byte[] b, int offset); static String hexdump(byte[] b, int offset, int len); static String strpadf(String s, int len); static String trimf(String s); static String takeLastN(String s,int n); static String takeFirstN(String s,int n); static String millisToString(long millis); static String formatAmountConversionRate(double convRate); static double parseAmountConversionRate(String convRate); static String commaEncode(String... ss); static String[] commaDecode(String s); static String commaDecode(String s, int i); static char calcLUHN(String p); static String getRandomDigits(Random r, int l, int radix); static String readableFileSize(long size); static String hexDump(byte[] array, int offset, int length, Charset charSet); static byte[] decodeHexDump(String s); }
ISOUtil { public static String dumpString(byte[] b) { StringBuilder d = new StringBuilder(b.length * 2); for (byte aB : b) { char c = (char) aB; if (Character.isISOControl(c)) { switch (c) { case '\r': d.append("{CR}"); break; case '\n': d.append("{LF}"); break; case '\000': d.append("{NULL}"); break; case '\001': d.append("{SOH}"); break; case '\002': d.append("{STX}"); break; case '\003': d.append("{ETX}"); break; case '\004': d.append("{EOT}"); break; case '\005': d.append("{ENQ}"); break; case '\006': d.append("{ACK}"); break; case '\007': d.append("{BEL}"); break; case '\020': d.append("{DLE}"); break; case '\025': d.append("{NAK}"); break; case '\026': d.append("{SYN}"); break; case '\034': d.append("{FS}"); break; case '\036': d.append("{RS}"); break; default: d.append('['); d.append(hexStrings[(int) aB & 0xFF]); d.append(']'); break; } } else d.append(c); } return d.toString(); } ISOUtil(); static String ebcdicToAscii(byte[] e); static String ebcdicToAscii(byte[] e, int offset, int len); static byte[] ebcdicToAsciiBytes(byte[] e); static byte[] ebcdicToAsciiBytes(byte[] e, int offset, int len); static byte[] asciiToEbcdic(String s); static byte[] asciiToEbcdic(byte[] a); static void asciiToEbcdic(String s, byte[] e, int offset); static void asciiToEbcdic(byte[] s, byte[] e, int offset); static String padleft(String s, int len, char c); static String padright(String s, int len, char c); static String trim(String s); static String zeropad(String s, int len); static String zeropad(long l, int len); static String strpad(String s, int len); static String zeropadRight(String s, int len); static byte[] str2bcd(String s, boolean padLeft, byte[] d, int offset); static byte[] str2hex(String s, boolean padLeft, byte[] d, int offset); static byte[] str2bcd(String s, boolean padLeft); static byte[] str2bcd(String s, boolean padLeft, byte fill); static String bcd2str(byte[] b, int offset,
                        int len, boolean padLeft); static String hex2str(byte[] b, int offset,
                                 int len, boolean padLeft); static String hexString(byte[] b); static String dumpString(byte[] b); static String hexString(byte[] b, int offset, int len); static String bitSet2String(BitSet b); static byte[] bitSet2byte(BitSet b); static byte[] bitSet2byte(BitSet b, int bytes); static int bitSet2Int(BitSet bs); static BitSet int2BitSet(int value); static BitSet int2BitSet(int value, int offset); static BitSet byte2BitSet(byte[] b, int offset, boolean bitZeroMeansExtended); static BitSet byte2BitSet(byte[] b, int offset, int maxBits); static BitSet byte2BitSet(BitSet bmap, byte[] b, int bitOffset); static BitSet hex2BitSet(byte[] b, int offset, boolean bitZeroMeansExtended); static BitSet hex2BitSet(byte[] b, int offset, int maxBits); static BitSet hex2BitSet(BitSet bmap, byte[] b, int bitOffset); static byte[] hex2byte(byte[] b, int offset, int len); static byte[] hex2byte(String s); static String byte2hex(byte[] bs); static byte[] int2byte(int value); static int byte2int(byte[] bytes); static String byte2hex(byte[] bs, int off, int length); static String formatDouble(double d, int len); static String formatAmount(long l, int len); static String normalize(String s, boolean canonical); static String stripUnicode(String s); static String normalize(String s); static String protect(String s, char mask); static String protect(String s); static int[] toIntArray(String s); static String[] toStringArray(String s); static byte[] xor(byte[] op1, byte[] op2); static String hexor(String op1, String op2); static byte[] trim(byte[] array, int length); static byte[] concat(byte[] array1, byte[] array2); static byte[] concat(byte[] array1, int beginIndex1, int length1, byte[] array2,
            int beginIndex2, int length2); static void sleep(long millis); static String zeroUnPad( String s ); static String blankUnPad( String s ); static String unPadRight(String s, char c); static String unPadLeft(String s, char c); static boolean isZero( String s ); static boolean isBlank( String s ); static boolean isAlphaNumeric( String s ); static boolean isNumeric( String s, int radix ); static byte[] bitSet2extendedByte( BitSet b ); static int parseInt(String s, int radix); static int parseInt(String s); static int parseInt(char[] cArray, int radix); static int parseInt(char[] cArray); static int parseInt(byte[] bArray, int radix); static int parseInt(byte[] bArray); static String hexdump(byte[] b); static String hexdump(byte[] b, int offset); static String hexdump(byte[] b, int offset, int len); static String strpadf(String s, int len); static String trimf(String s); static String takeLastN(String s,int n); static String takeFirstN(String s,int n); static String millisToString(long millis); static String formatAmountConversionRate(double convRate); static double parseAmountConversionRate(String convRate); static String commaEncode(String... ss); static String[] commaDecode(String s); static String commaDecode(String s, int i); static char calcLUHN(String p); static String getRandomDigits(Random r, int l, int radix); static String readableFileSize(long size); static String hexDump(byte[] array, int offset, int length, Charset charSet); static byte[] decodeHexDump(String s); static final String[] hexStrings; static final String ENCODING; static final Pattern unicodePattern; static final Charset CHARSET; static final Charset EBCDIC; static final byte STX; static final byte FS; static final byte US; static final byte RS; static final byte GS; static final byte ETX; }