Java Hex Convert To convertHextoASCII(String text)

Here you can find the source of convertHextoASCII(String text)

Description

convert Hexto ASCII

License

Open Source License

Declaration

public static String convertHextoASCII(String text) 

Method Source Code

//package com.java2s;
/**/*from  w  ww  . java2 s .  c o  m*/
 * Copyright (c) 2010-2015 Bryan Beck.
 * All rights reserved.
 * 
 * This project is licensed under LGPL v2.1.
 * See jMovieManager-license.txt for details.
 * 
 */

public class Main {

    public static String convertHextoASCII(String text) {
        String convertedString = text;
        String replacement;
        int decimal;
        int iStart;

        while (convertedString.contains("&#x")) {
            iStart = convertedString.indexOf("&#x");
            replacement = convertedString.substring(iStart + 3, iStart + 5);
            decimal = Integer.parseInt(replacement, 16);
            replacement = ((char) decimal) + "";
            convertedString = convertedString.replaceFirst("&#x[A-Z0-9]{2};", replacement);
        }

        convertedString = convertedString.replace("'", "'");
        convertedString = convertedString.replace('"' + "", "");
        convertedString = convertedString.replace(""", "");
        return convertedString;
    }
}

Related

  1. convertHexColorToRgb(final String hex)
  2. convertHexFloatingPointLiteralToBits(char[] source)
  3. convertHexLong(String hex)
  4. convertHexStringToBinary(String hexString)
  5. convertHexTime2Binary(String timespan)
  6. convertHexToChar(String hex)
  7. convertHexToFloat(long hexValue)
  8. fromHex(byte[] hex)
  9. fromHex(char c)