0 Replies - 444 Views - Last Post: 26 March 2019 - 11:35 AM

#1 dylan009   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 04-March 19

Issue with String encoding for Android mobile application

Posted 26 March 2019 - 11:35 AM

[size="4"][font="Times New Roman"][size="7"][size="6"]
I am doing project in Android mobile development. I have some requirement where I need to do string encoding.

The code I have is :
String x="Sav� Moi!";
System.out.println("before replacing value is :" + (URLUtil.urlEncode(x.trim())));



I am getting output as
Sav%C3%A9+Moi%21
.

So I need to replace + symbol with %20 so I wrote it as

System.out.println("after replacement value is :" + (URLUtil.urlEncode(x.trim()).replaceAll("\\+", "%20")));


then the output is Sav%C3%A9%20Moi%21

but here I am hard coding %20 . So I want any alternate method for this.
can anybody help me?

Reference Example

Is This A Good Question/Topic? 0
  • +

Page 1 of 1