Log in

View Full Version : Resolved url encode %A0 vs. %20



james438
05-09-2012, 07:03 AM
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.

djr33
05-09-2012, 08:06 AM
[Wrong answer removed -- see jscheuer1's post for correct info.] :)

jscheuer1
05-09-2012, 10:31 AM
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   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.

james438
05-10-2012, 03:59 AM
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!