var str = String.fromCharCode( 65 ); // 65 = uppercase 'A'
alert( str );
var str = String.fromCharCode( 83, 67, 82, 73, 80, 84 );
alert( str ); // Click to run and reveal the string! ->
function fromCharCode( $charCode ) {
$strToConvert = '&#' . intval( $charCode ) . ';';
return mb_convert_encoding( $strToConvert, 'UTF-8', 'HTML-ENTITIES' );
}
For a more modular approach, you could expand this same function to handle either a single argument, or an array of them (and cycles through, just like JavaScript's method does).Sister method: charAt() returns the character found at the position index passed as argument. And charCodeAt() returns the Unicode value for the character found at that index.