/ Published in: JavaScript
Expand |
Embed | Plain Text
String.prototype.ncr2c = function( ) { return this .replace( /&#x([\da-f]{2,4});/gi, function( $0, $1 ) { return String.fromCharCode( "0x" + $1 ) } ) } String.prototype.c2ncr = function( ) { return this .ncr2c( ).replace( /./g, function( $0 ) { return "&#x" + $0.charCodeAt( ).toString( 16 ).toUpperCase( ) + ";" } ) } alert( "ajax".ncr2c( ) ); //ajax alert( "ajax".c2ncr( ) ); //ajax
You need to login to post a comment.
