Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript escape() function and + symbol

    Hi everyone,

    I am working on a JSP web application using the Spring framework. I am having trouble with URI encoding for form submission when it comes to the javascript escape() function and the + symbol. The symbol is sent to the server unescaped but when it is decoded by the request object on the server side, the + is converted into a space. So for example, if "C++" is submitted in a form, it is decoded on the server side as "C ".

    I am wondering if anyone could give me a suggestion for how to solve this problem. Unfortunately using the encodeURI() function is not an option as we are using iso-8859-1 encoding on the server side (it is an intranet application), and changing the server behaviour is not an option for me at this point. Since encodeURI() encodes in UTF-8 format, I end up with this when I use it instead of escape():

    Input: développeur
    Output: dã©veloppeur

    Thanks in advance for any help you can provide!

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You could pre-convert the + symbols into something else - something you can recognise and feel confident is unique on the other end, for example something like "~~":

    Code:
    str = str.replace(/(\+\+)/g, '~~');
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #3
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you very much brothercake, your tip was a huge help. I ended up replacing '+' with the ascii code (%2B) and the server side decoded everything properly. I appreciate the help.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •