• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to escape % in string passed to URLDecoder.decode(String)?

 
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All
I am trying to pass a message to URLDecoder.decode method which might contain % charecter. But when this charecter is inside the message, decode method will treat it as escape charecter and treats next two digits as hex-digits. If there are NO two digits at last and if % is the last letter, then am getting an exception


Could someone help me out on how to escape % in message before passing message to decode method?

Appreciate all. Thanks.
 
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know of a library method that does this, but then I've never looked for one. I guess you'll have to search for %s that aren't followed by two digits - probably a regexp search - then replace with %. (Assuming this code is correct, I found it here).


--Tim
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim.
 
reply
    Bookmark Topic Watch Topic
  • New Topic