Get unicode value of character

橙三吉。 提交于 2019-11-29 16:14:59
char ch='c';
int code = ch;
System.out.println(code);

OUTPUT:

99

just for escape char \ you have to use like char ch='\\';

A way is this:

char c = 'f';

System.out.println("code="+(int)c);

I mean, you should make a casting form char to int;

Lex Luthor
public static int KeyEvent.getExtendedKeyCodeForChar( int key );

This will return an extended key code for the unicode character key.

As stated at here:

Returns: for a unicode character with a corresponding VK_ constant -- this VK_ constant; for a character appearing on the primary level of a known keyboard layout -- a unique integer. If a character does not appear on the primary level of a known keyboard, VK_UNDEFINED is returned.

System.out.println((int) 'c');

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!