android uft-8 character conversion to symbols

1.2k views Asked by At

In my android app my server returns a UTF-8 encoded response like this; \u00e2\u0080\u0098 rank \u00e2\u0080\u0099 which is equivalent 'rank'. Kindly help me in converting this Unicode characters to corresponding symbols i.e

1.\u00e2\u0080\u0098 -> ' (LEFT SINGLE QUOTATION)

2.\u00e2\u0080\u0099 -> ' (RIGHT SINGLE QUOTATION)

1

There are 1 answers

1
keshav On

This is the way, replace "some text" with ur string -

   String s1 = "some text";
        String s2 = "";
        byte[] bytes;
        try {
            bytes = s1.getBytes("UTF-8");
             s2 = new String(bytes, "UTF-8"); // Charset with which bytes were encoded
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

s2 have required string.