Encoding useragent

What can be used to encode a user agent to make:


Rather than:

$ua = urlencode($_SERVER['HTTP_USER_AGENT']);

Which gives this format:


Must a function be written?

Would rawurlencode do what you are after?

Have you got the original USER AGENT you are using?

Actually I’ve come up with this, which seems to at least given a matching string.

$ua2 = "$ua";
$ua2 = str_replace('%2F', '/', $ua2);
$ua2 = str_replace('%3B',';',$ua2);
$ua2 = str_replace('%3A', ':', $ua2);
$ua2 = str_replace('+' , '%20' , $ua2);

But the reason I am doing this, is for a SimplePie feed (believe there is no more support there).

And to my utter amazement, even when the output of a test string exactly matches one that is character entered (which succeeds), the request fails.

Given what I am faced with, which does not make sense, I don’t know if there is anything else I can do with this.

Would rawurlencode do what you are after?
Comes up with something different.

Ok, have you the original string used for the encode?

Looks like:

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20101203 Firefox/3.6.13

sorry for the double post but the system would not allow an edit, and this may save some time:

I’ve recompared and the start and end brackets were omitted, but the request is still not cooperating. Gone over char per char.

$ua2 = “$ua”;
$ua2 = str_replace(‘%2F’, ‘/’, $ua2);
$ua2 = str_replace(‘%3B’,‘;’,$ua2);
$ua2 = str_replace(‘%3A’, ‘:’, $ua2);
$ua2 = str_replace(‘+’ , ‘%20’ , $ua2);
$ua2 = str_replace(‘(’ , ‘%28’ , $ua2);
$ua2 = str_replace(‘)’ , ‘%29’ , $ua2);