0

I am hitting server and getting some data in string format.

in this data there are some special character like - ' . but when i set that string in textview these special character convert into ? .

So how can i avoid this issue ? please help.

first try :

  String t = "<![CDATA["+title+"]]>";
        mTitle.setText(Html.fromHtml(text));

second try :

 String base64 = Base64.encodeToString(getTitle().getBytes(), Base64.DEFAULT);
        byte[] data = Base64.decode(base64, Base64.DEFAULT);
        String text = new String(data, StandardCharsets.UTF_8);
        mTitle.setText(text);
nitin tyagi
  • 1,176
  • 1
  • 19
  • 52

1 Answers1

0

Try this:

tv.setText(news_item.getTitle().replaceAll("\u2019", "&#39;"));

Refer this link for unicode encoding.

Anas Azeem
  • 2,820
  • 3
  • 24
  • 37