Hello, the question is this: there is an EditText from which I get a string in which there can be Cyrillic characters. How do I convert this string to escape \ u-codes?

    1 answer 1

    Use Apache Commons StringEscapeUtils

    String escapedString=StringEscapeUtils.escapeJava("Привет"); 

    Adding to the project:

     compile 'org.apache.commons:commons-lang3:3.6' 
    • thanks It works. Maybe you still know how to transfer this string in JSON so that it does not work: \\ u043F \\ u0440 \\ u0438 \\ u0432 \\ u0435 \\ u0442, but with single slashes? - Heorhii Lysenko
    • Design the question according to the rules of the stack - Barmaley