I have a string representing the hex value of a char, for example: "0x6d4b". How can I get the character that it represents as char?
String c = "0x6d4b"; char m = ???
// Drop "0x" in order to parse String c = "6d4b"; // Parse hexadecimal integer int i = Integer.parseInt( c, 16 ); // Note that this method returns char[] char[] cs = Character.toChars( i ); // Prints ζ΅System.out.println( cs );
String s = "6d4b"; int i = Integer.parseInt( s, 16 ); // to convert hex to integer char ca= (char) i; System.out.println(ca);
System.out.println((char)Integer.parseInt("6d4b",16));
Try it,
String s ="0x6d4b" ; char[] c = s.toCharArray(); for (char cc : c){ System.out.print(cc); }
Source: https://habr.com/ru/post/919099/More articles:Set string with specified length in PHP - stringselenium, how can I select a new window - javaandroid.os.StrictMode instances = 2; limit = 1 - javaHow to find a file name given a FILE pointer? - cGet file name from file pointer in C - cHow to get file_name with file *? - c ++Google App Engine 409 deployment error - javaDetermining the (open) file name from the FILE * file - cXML for POJO and vice versa - javaHow to resize thumb image UISlider programmatically - iosAll Articles