Jump to content

Can anyone convert this javascript to php?


pepsi599ml

Recommended Posts

Hi, I'm wondering if it's possible to convert this javascript code to php.

The code itself converts Chinese (gb2312 encoding) characters to unicode format (&#x####;).

I know iconv can do this, but some special characters are lost during the conversion anyway.

And I found this simple javascript does the work very well, so here it is, just a line.

 

str.value = str.value.replace(/[^\u0000-\u00FF]/g,function($0){return escape($0).replace(/(%u)(\w{4})/gi,"&#x$2;")});

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.