Results 1 to 3 of 3
Thread: Character decoding, anyone help?
-
09-01-2006, 04:49 AM #1
Character decoding, anyone help?
Ok, I'm a bit stumped here, and could use some help trying to figure this one out.
I'm in the process of importing helpdesk entries from one piece of software to another. That part, for the most part is reasonably easy. The problem I'm seeing, however is that this helpdesk software is storing these entries using some sort of encoding (at first I thought it was utf-8, but I'm stumped now). I've written a bit of a function to decyper this stuff, but it would be NICE to actually figure out what this was, if anyone can.. Here's a bit of what the entries look like in the sql db.
Updating+%2Fscripts+...%0ASync+Source%3A+http%3A%2F%2Fhttpupdate.cpanel.net%2FRELEASE%2Fscripts%0AFetching+http%3A%2F%2Fhttpupdate.cpanel.net%2Fcpanel sync%2FRELEASE%2Fscripts%2F.cpanelsync.lock+%280%29....%40198.66.78.12......connected......receiving...100%25......Done%0AFetching+http%3A%2F%2Fhttpup date.cpanel.net%2Fcpanelsync%2FRELEASE%2Fscripts%2F.cpanelsync.bz2+%280%29
PHP Code:function cleanup($string)
{
$string=str_replace('%0D', '<br \>', $string);
$string=str_replace('%0A', '<br \>', $string);
$string=str_replace('%2F', '/', $string);
$string=str_replace('%7D', ')', $string);
$string=str_replace('%7B', '(', $string);
$string=str_replace('+',' ', $string);
$string=str_replace('%3A',':', $string);
$string=str_replace('%5B','[', $string);
$string=str_replace('%5D',']', $string);
$string=str_replace('%2C',',', $string);
$string=str_replace('%3B',',', $string);
$string=str_replace('%40','@', $string);
$string=str_replace('%3D','<', $string);
$string=str_replace('%3E','>', $string);
$string=str_replace('%3F','?', $string);
$string=str_replace('%5C%5C%5C%27','\'', $string);
return $string;
}
Tom Whiting, WHMCS Guru extraordinaire
Linux problems? WHMCS Problems? Give me a shout
Check out my WHMCS Addons
-
09-01-2006, 04:54 AM #2the cloud is a lie
- Join Date
- May 2004
- Location
- NYC
- Posts
- 793
The string is a url-encoded string. Use the php urldecode() function to replace the + sign with a space, #XX with meaningful characters, etc:
Code:$string = urldecode($encoded_string);
-
09-01-2006, 05:49 AM #3
Aye, url-encode it was. I knew there was something stupid I was missing somewhere. Thank you!!!!
Tom Whiting, WHMCS Guru extraordinaire
Linux problems? WHMCS Problems? Give me a shout
Check out my WHMCS Addons