Java ASCII asciify(String s)

Here you can find the source of asciify(String s)

Description

Converts the characters in the given string to equivalent ascii value.

License

Open Source License

Parameter

Parameter Description
String s - The string to be converted.

Exception

Parameter Description
None an exception

Return

String - The ascii equivalent of the given string.

Declaration

static String asciify(String s) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from  w w w  .  j av  a 2 s  .c o  m
    *   Converts the characters in the given string to equivalent ascii value.
    *   The string is assumed to be double quoted properly.
    *   
    *   @param String s - The string to be converted.
    *   @return String - The ascii equivalent of the given string.
    *   @throws None
    */
    static String asciify(String s) {

        String temp = "\"";

        for (int i = 1; i < s.length() - 1; i++)
            temp += String.format("%2X", (int) s.charAt(i)).replace(' ', '0');

        return temp + "\"";
    }
}

Related

  1. asciiEbcdic(String source)
  2. asciiEndsWithIgnoreCase(String source, String suffix)
  3. asciiEqualsIgnoreCase(byte[] a, byte[] b)
  4. asciiEqualsIgnoreCase(byte[] buf1, byte[] buf2)
  5. asciiFill2(String str, int startIdx, String fillStr)
  6. asciiIdx2StrIdx(String str, int asciiIdx)
  7. asciiLength(String str)
  8. asciiPaddingR(String str, int length, String padding)
  9. asciiQuads(String word)