Java decoding of javascript encodeURIComponent?

Discussion in 'Java' started by AlextLittle@googlemail.com, Mar 15, 2007.

  1. Guest

    Hi,
    I'm attempting to retrieve (in my servlet) the values from a url
    parameter which have been encoded with javascript encodeURIComponent,
    because they contain non-latin characters (and/or punctuation) but I
    can't seem to get it to work correctly - i.e. it's not converting the
    characters back correctly.

    In my serlvet I've set: request.setCharacterEncoding("UTF-8"); then I
    try to use:

    String groups = params.getParameter("groups");
    String decodedParam = URLDecoder.decode(groups,"UTF-8");

    But if I then try to compare decodedParam against the original strings
    (used to previously generate the webpage), I can't get them to match
    if any non-latin chars are in the decodedParam. - the following
    results in 'found' messages when decodedParam is purely latin chars
    and 'not found' messages non-latin chars included:

    if(originalGroupName.equals(decodedParam)){
    System.out.println("found:"+originalGroupName);
    } else {
    System.out.println("not found:"+originalGroupName);
    }


    Any ideas where I might be going wrong as it's driving me a little
    mad!!
    All help much appreciated ;-)
    Alex
    , Mar 15, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. int80
    Replies:
    4
    Views:
    13,831
    randomguy
    Aug 25, 2008
  2. Merrick
    Replies:
    2
    Views:
    626
    Bruno Desthuilliers
    Oct 6, 2008
  3. Danny Vucinec

    encodeURIComponent vs. escape

    Danny Vucinec, Sep 7, 2007, in forum: ASP General
    Replies:
    2
    Views:
    378
    Danny Vucinec
    Sep 13, 2007
  4. Cloink
    Replies:
    20
    Views:
    846
    Charlton Wilbur
    Jan 24, 2007
  5. Cloink
    Replies:
    4
    Views:
    1,162
    Dr.Ruud
    Jan 23, 2007
Loading...

Share This Page