Search code examples
javascriptcodepages

convert string or character to hex codes in javascript


I have a hex code table like this:

enter image description here

the code for "خ" is "A0" . now I want to write a function to get character or string and convert it to hex codes! how can I do that??

the language is Persian or Farsi .


Solution

  • As I searched and searched and tested, the only way was to convert charecter by character in a very long if-else-if statement !! It was also printed backward so I had to revert the string first. then numbers and english letters would be reversed so I had to made them reverse again!! It was a headache but worked!