Itay S :
I need to get the ANSI value of a char in java
Ive tried casting my char to an int type but it returns a value that is not its ANSI value.
is there any way to do this?
one letter in hebrew which is "ל" has the ansi value of 236 but when i cast it to int i get 1500
Erwin Bolwidt :
What you call "ANSI" is actually the Windows codepage 1255 character set (Windows-1255
). It's the Hebrew codepage from Microsoft.
You can get your character value in that encoding using the following code:
public static void main(String[] args) throws UnsupportedEncodingException {
String s = "ל";
byte[] b = s.getBytes("Windows-1255");
System.out.println(b[0] & 0xff);
}
This prints:
236
(Note: this also works on other operating systems than Windows, such as MacOS)
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=310545&siteId=1