pepsi599ml Posted November 14, 2008 Share Posted November 14, 2008 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;")}); Link to comment https://forums.phpfreaks.com/topic/132668-can-anyone-convert-this-javascript-to-php/ Share on other sites More sharing options...
cunoodle2 Posted November 14, 2008 Share Posted November 14, 2008 I would try posting this question in this form here... http://www.phpfreaks.com/forums/index.php/board,43.0.html That will specifically do what you are looking for. Good luck with this =) Link to comment https://forums.phpfreaks.com/topic/132668-can-anyone-convert-this-javascript-to-php/#findComment-689983 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.