Results 1 to 4 of 4

Thread: url encode %A0 vs. %20

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    1,692
    Thanks
    82
    Thanked 90 Times in 88 Posts

    Default url encode %A0 vs. %20

    This is not exactly a php question so feel free to move it if needed.

    I notice that when I submit a a memo post with a tag that has a space in it the tag occasionally is encodes the space as %A0 and at other times as %20. Both seem to be the code for a space, but what is the difference? I need to know so that I can keep the spaces submitted as %20 as opposed to %A0, which would end up creating a duplicate tag in my database.

    My efforts to determine the difference have not been successful so far.
    Last edited by james438; 05-11-2012 at 05:26 PM.
    To choose the lesser of two evils is still to choose evil. My personal site

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    [Wrong answer removed -- see jscheuer1's post for correct info.]
    Last edited by djr33; 05-09-2012 at 02:02 PM.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,192 Times in 3,155 Posts
    Blog Entries
    12

    Default

    No. %A0 is the non-breaking space while %20 is the space. You haven't shown the code used. Adding a line that replaces %A0 with %20 before evaluating for duplicates should take care of it.

    Also be aware that %a0 and %A0 are equivalent. Depending upon how the encoding is done, you may or may not have to account for both of them. Optionally you could replace the character before it's encoded. \xa0 should catch them all, unless they're represented as &nbsp; entities.

    And under circumstances where line wrapping is involved, there is a difference in how these characters display, so unless you're certain it's leading to duplicate entries, I'd leave it alone.
    Last edited by jscheuer1; 05-09-2012 at 10:37 AM. Reason: add info
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. The Following User Says Thank You to jscheuer1 For This Useful Post:

    djr33 (05-09-2012)

  5. #4
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    1,692
    Thanks
    82
    Thanked 90 Times in 88 Posts

    Default

    I will replace the character before it is encoded. What was happening was I was writing a post and copied a longish tag that I wanted to use from the list of available tags and pasted it onto the textarea used for tags. The script then scanned the database to see if the tag was already being used and since it recognized the spaces in the tag I pasted as a non-breaking space, %A0, as opposed to the regular space, %20, it thought the tag was a new one and created a new tag and applied it to the post.

    The tag in question is "reformat hard drive". I am about to reformat my hard drive. I think it is a good practice to do this once every year or two to keep things running smooth. It is a bit of a chore, but has always been worth it.

    Now that I know what %A0 is this should be an easy fix. Thanks for the help!
    To choose the lesser of two evils is still to choose evil. My personal site

Bookmarks

Posting Permissions

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