Java Utililty Methods ASCII from

List of utility methods to do ASCII from

Description

The list of methods to do ASCII from are organized into topic(s).

Method

StringtoASCII(String s)
Converts a non ASCII string to an ASCII string.
StringBuffer sb = new StringBuffer();
int n = s.length();
for (int i = 0; i < n; i++) {
    char c = s.charAt(i);
    int pos = UNI_CODE.indexOf(c);
    if (pos > -1) {
        sb.append(PLAIN_ASCII.charAt(pos));
    } else {
...
StringtoAscii(String s)
to Ascii
if (s == null) {
    return null;
StringBuilder sb = new StringBuilder(s.length());
int n = s.length();
int i = 0;
while (i < n) {
    char c = s.charAt(i);
...
StringtoASCII(String str)
to ASCII
StringBuffer strBuf = new StringBuffer();
byte[] bGBK = str.getBytes();
for (int i = 0; i < bGBK.length; i++) {
    strBuf.append(Integer.toHexString(bGBK[i] & 0xff));
return strBuf.toString();
byte[]toAsciiArray(char[] carr)
Converts char array into ASCII array.
if (carr == null)
    return null;
byte[] barr = new byte[carr.length];
for (int i = 0; i < carr.length; i++)
    barr[i] = (byte) toAscii(carr[i]);
return barr;
byte[]toAsciiByteArray(final char[] carr)
to Ascii Byte Array
final byte[] barr = new byte[carr.length];
for (int i = 0; i < carr.length; ++i) {
    barr[i] = (byte) ((carr[i] <= '\u00ff') ? carr[i] : '?');
return barr;
byte[]toAsciiByteArray(String s)
to Ascii Byte Array
char[] chars = s.toCharArray();
int len = chars.length;
byte[] buffer = new byte[len];
for (int i = 0; i < len; i++) {
    buffer[i] = (byte) (chars[i] & 0xff);
return buffer;
byte[]toAsciiBytes(final String value)
Convert specified String to a byte array.
byte[] result = new byte[value.length()];
for (int i = 0; i < value.length(); i++) {
    result[i] = (byte) value.charAt(i);
return result;
byte[]toAsciiBytes(String str)
to Ascii Bytes
for (int i = 0; i < str.length(); i++) {
    if (str.charAt(i) > 127)
        return null;
byte[] bytes = new byte[str.length()];
for (int i = 0; i < str.length(); i++) {
    bytes[i] = (byte) str.charAt(i);
return bytes;
chartoAsciiChar(byte b)
to Ascii Char
char c = (char) b;
return Character.isISOControl(c) ? '.' : c;
CharactertoAsciiChar(int i)
Mengkonversi bilangan desimal ke karakter ASCII
return new Character((char) i);