android - How to replace ASCII Text with Hex Value -


i have string

msg = "hello.. welcome. id 'abcd' & pwd '123' !!";

i'm replacing white spaces

msg = msg.replaceall("\\s+", "%20");

result is

msg = "hello..%20welcome.%20your%20id%20is%20'abcd'%20&%20pwd%20is%20'123'!!

how replace ascii text (&, ' , " , !) etc hex value.

which results in string like

msg = "hello..%20welcome.%20your%20id%20is%20%27abcd%27%20%26%20pwd%20is%20%27123%27%21%21 

try this,

string query = urlencoder.encode(msg, "utf-8").replace("+", "%20"); 

edit

this better way.

string url = uri.parse(msg)                 .buildupon()                 .build()                 .tostring(); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -