java native2ascii.exe的java版本

java

笔者周末在家逆向jdk源码,得到以下方法

    public static void main(String[] args){

System.out.println(native2ascii("hh汉字"));

}

static String native2ascii(String originalText)

{

final StringBuffer stringBuffer = new StringBuffer();

char[] array = originalText.toCharArray();

int n2 = array.length;

for (int i = 0; i < n2; ++i) {

if (array[i] > '\u007f') {

stringBuffer.append((char) 92);

stringBuffer.append((char)117);

final StringBuffer sb = new StringBuffer(Integer.toHexString(array[i]));

sb.reverse();

for (int n3 = 4 - sb.length(), j = 0; j < n3; ++j) {

sb.append('0');

}

for (int k = 0; k < 4; ++k) {

stringBuffer.append(sb.charAt(3 - k));

}

}

else {

stringBuffer.append(array[i]);

}

}

return stringBuffer.toString();

}

输出结果等同于 native2ascii.exe里面执行命令

以上是 java native2ascii.exe的java版本 的全部内容, 来源链接: utcz.com/z/390600.html

回到顶部