Java Utililty Methods Native to ASCII

List of utility methods to do Native to ASCII

Description

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

Method

Stringnative2ascii(String code)
nativeascii
char[] chars = code.toCharArray();
int charValue = 0;
String result = "";
for (int i = 0; i < chars.length; i++) {
    charValue = (int) code.charAt(i);
    if (charValue <= 256) {
        result += "\\" + Integer.toHexString(charValue);
    } else {
...
Stringnative2ascii(String line)
Replaces non-ASCII characters with their Unicode-Escapes.
StringBuilder sb = new StringBuilder();
for (char c : line.toCharArray()) {
    if (c <= MAX_ASCII) {
        sb.append(c);
    } else {
        sb.append("\\u");
        String encoded = Integer.toHexString(c);
        for (int i = encoded.length(); i < 4; i++) {
...
Stringnative2Ascii(String s)
Converts a string from the Unicode representation into something that can be embedded in a java properties file.
StringBuffer sb = new StringBuffer();
for (int i = 0; i < s.length(); i++) {
    char aChar = s.charAt(i);
    if ((aChar < 0x0020) || (aChar > 0x007e)) {
        sb.append('\\');
        sb.append('u');
        sb.append(toHex((aChar >> 12) & 0xF));
        sb.append(toHex((aChar >> 8) & 0xF));
...
Stringnative2AscII(String str)
native Asc II
if (str == null)
    return null;
char[] charPoints = str.toCharArray();
StringBuffer strBuf = new StringBuffer();
for (char ch : charPoints) {
    if (ch < 256)
        strBuf.append(ch);
    else
...
StringnativeToAscii(String input)
native To Ascii
if (input == null) {
    return null;
StringBuffer buffer = new StringBuffer(input.length() + 60);
for (int i = 0; i < input.length(); i++) {
    char c = input.charAt(i);
    if (c <= 0x7E) {
        buffer.append(c);
...