Pure-Essence.Net

javascript unescape like php function

Posted by: pureessence on: March 29, 2005

when you start dealing with languages (i.e. chinese) that require 8 bit encoding or more, you will learn about all the wonderful jazz of utf8, unicode, ISO etc. i was looking all over for a php function that does what javascript unescape does. normally rawurldecode would work, but…

not on utf8 strings. my problem is i saved my chinese into a browser cookie and then i wish php to read and translate it to unicode for the browser to display.
for example, i’d like php to translate the utf8 string:
%u6211%u662F%u8C46%u8C46
to:
我是豆豆
to display:
我是豆豆

it ran into problems and i couldn’t find a way for php to translate that. thank god for this nifty function :)

Advertisement

6 Responses to "javascript unescape like php function"

Did you write that function yourself? *is amazed* :biggrin:

no i didn’t.. i found it

I was searching for something similar and found your blog… but the link you provided is dead – could you please resurrect it? :)

Hi,

any chances to the link working ? I’m dreaming about this function.

Please,

Regards

try this one

function unicode_decode($txt) {
return ereg_replace(‘%u([[:alnum:]]{4})’, ‘&#x\1;’,$txt);
}


micrub:

try this one
function unicode_decode($txt) {
return ereg_replace(?%u([[:alnum:]]{4})?, ??,$txt);
}

thanks, this works great, except for the character “ő”, but i think i can manage this from here :)

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

My most adorable Pomeranians

Categories

Archives

SocialVibe


Follow

Get every new post delivered to your Inbox.