Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert a get a character's unicode(?) value? [closed]

I need to convert a char to an int and back.

Here's what I'm using to convert the char to an int:

(char)65 // Returns 'a'

Here's what I'm TRYING to use to convert it back:

(int)'a' // Returns 97

Any ideas what I can do?

like image 299
user1438378 Avatar asked Oct 17 '12 23:10

user1438378


Video Answer


2 Answers

try this,

char x = 'a';
int y = (int)x;
like image 168
John Woo Avatar answered Oct 23 '22 22:10

John Woo


65 is the character code for a capital 'A'. 97 is a lower case 'a'.

like image 36
Stephen Hewlett Avatar answered Oct 23 '22 20:10

Stephen Hewlett