sql:
select ASCII([NUMBER]) , ASCII(SUBSTRING([NUMBER], 2, 1)) from testtable where id= '1'
数据:id=1,NUMBER=彐
sql返回结果:229,230
想在java代码里,把字符串“彐”转成229和230
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));
}
}