Java ASCII AsciiStringToString(String content)

Here you can find the source of AsciiStringToString(String content)

Description

Ascii String To String

License

Open Source License

Declaration

public static String AsciiStringToString(String content) 

Method Source Code

//package com.java2s;

public class Main {

    public static String AsciiStringToString(String content) {
        String result = "";
        int length = content.length() / 2;
        for (int i = 0; i < length; i++) {
            String c = content.substring(i * 2, i * 2 + 2);
            int a = hexStringToAlgorism(c);
            char b = (char) a;
            String d = String.valueOf(b);
            result += d;/* ww w  . java  2  s.c  om*/
        }
        return result;
    }

    public static int hexStringToAlgorism(String hex) {
        hex = hex.toUpperCase();
        int max = hex.length();
        int result = 0;
        for (int i = max; i > 0; i--) {
            char c = hex.charAt(i - 1);
            int algorism = 0;
            if (c >= '0' && c <= '9') {
                algorism = c - '0';
            } else {
                algorism = c - 55;
            }
            result += Math.pow(16, max - i) * algorism;
        }
        return result;
    }
}

Related

  1. asciiLength(String str)
  2. asciiPaddingR(String str, int length, String padding)
  3. asciiQuads(String word)
  4. asciiString(byte[] bytes, int from, int count)
  5. asciiString(String fourcc)
  6. asciiToBCD(byte[] ascii, int asc_len)
  7. asciiToEbcdic(String s)
  8. ASCIIToInteger(String ascii)
  9. asciiValue(byte b)