Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
167
rated 0 times [  170] [ 3]  / answers: 1 / hits: 61341  / 11 Years ago, sat, december 14, 2013, 12:00:00

Hey all i am in need of something simple to convert character(s) into ASCII and then make that into a Hex code.



So as an example the A character would be:



0xF100 + ascii_code = Hex


and that would turn out to be:



0xF100 + 65 = 0xF141


65 would be the character A above. I've been looking for some javascript that would take my character and make a Hex from it... But i haven't really found anything that would do this....



Any help would be great!


More From » string

 Answers
9

Number's toString accepts a radix parameter, with which you can convert the ASCII code to hexadecimal like this:



var data = A;
console.log(0xF1 + data.charCodeAt(0).toString(16));


16 means base 16, which is hexadecimal.


[#73734] Thursday, December 12, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sandra

Total Points: 708
Total Questions: 100
Total Answers: 84

Location: Bosnia and Herzegovina
Member since Thu, Jun 24, 2021
3 Years ago
sandra questions
Tue, Jun 30, 20, 00:00, 4 Years ago
Sun, May 31, 20, 00:00, 4 Years ago
Wed, May 20, 20, 00:00, 4 Years ago
Fri, May 31, 19, 00:00, 5 Years ago
;