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

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -