You must obtain character codes in Unicode. For the standard, you can take the phrase:

Gaidai some

0433 0430 0439 0434 0430 0439 0020 043a 0430 043a 043e 0439 002d 0442 043e

Codes coincide with the codes from this table .

How to make such a transformation?

    2 answers 2

    And char in int did not try?

     String s = "привет мир"; for (char c : s.toCharArray()) { int code = (int)c; System.out.format("%04X ", code); } 

    gives out

     043F 0440 0438 0432 0435 0442 0020 043C 0438 0440 
    • I am amazed, yes you are right Java - guru! - Flippy
    • 2
      @Flippy: I also know how to embroider on a typewriter! And the cross (c) - VladD
    • @VladD Thank you! - Pax Exterminatus
    • @PaxExterminatus: Please! - VladD

    Getting UNICODE codes in string

     String prContentFormatHex = ""; for (char c : prContent.toCharArray()) { int code = (int)c; prContentFormatHex += String.format("%04X ", code); } 

    Getting GSM7 codes (GSM 7-bit default alphabet (Hexadecimal)) in the string. Only for Latin!

    Appendix: GSM 7-bit Default Alphabet Table (with Character Codes of ISO 8859 Latin 1)

     if (prContentFormatCoding == 0) { //Кодирование для GSM7 for (char c : prContent.toCharArray()) { int code = (int)c; prContentFormatHex += String.format("%X ", code); } } 

    Examples of displaying strings in UNICODE codes

    • Hi My Name Is Slim Shady

    0048 0069 0020 004D 0079 0020 004E 0061 006D 0065 0020 0049 0073 0020 0053 006C 0069 006D 0020 0053 0068 0061 0064 0079

    • In my mouth, feet, quickly!

    0412 0020 0440 043E 0442 0020 043C 043D 0435 0020 043D 043E 0433 0438 002C 0020 0431 044B 0441 0442 0440 043E 0021

    Examples of displaying strings in GSM7 codes

    • Hi my name is

    48 69 20 4D 79 20 4E 61 6D 65 20 49 73