sql:
select ASCII([NUMBER]) , ASCII(SUBSTRING([NUMBER], 2, 1)) from testtable where id= '1'
数据:id=1,NUMBER=彐
sql返回结果:229,230
想在java代码里,把字符串“彐”转成229和230
import lombok.SneakyThrows;
import java.nio.charset.StandardCharsets;
public class Test {
@SneakyThrows
public static void main(String[] args) {
String s="彐";
System.out.println("彐");
byte[] gbks = s.getBytes("gbk");
System.out.println(((int) gbks[0]& 0x0FF));
System.out.println(((int) gbks[1]& 0x0FF));
}
}
package Change;
public class TrunChange {
public static void main(String[] args) {
String s="0000012342";
int a =Integer.parseInt(s);
System.out.println("还没有为装换之前的字符串为:"+s);
System.out.println("转换之后的数字为:"+a);
}
}
java 转 ASCII 直接char转int输出就行,但你这个字符输出不是229呀
public static void main(String[] args) {
char ch1 = 'a';
char ch2 = 'b';
int int1 = ch1;
int int2 = ch2;
System.out.println("The ASCII value of " + ch1 + " is: " + int1);
System.out.println("The ASCII value of " + ch2 + " is: " + int2);
}