FromCharCode()

Convert UTF-16 (16-bit Unicode Transformation Format) code units to string.
document.write(String.fromCharCode(70)); // output F
Total range of UTF-16 values are from 0 and 65535. The first 128 unicode value are direct match of ASCII chars. We can get a string output by using fromcharcode.
document.write(String.fromCharCode(70,71,72));// Output is FGH
Let us try to print all the chars by using a for loop and displaying Unicode value and char The ASCII table ( 0 to 127 )
<script type="text/javascript">
document.write("<table>");
for(var i=0;i<=127;i++){
if( i%5 ==0){document.write ("</tr><tr>");}
document.write("<td>" + i + ' = '+String.fromCharCode(i) + "</td>");
}
document.write("</tr></table>");
</script>
The extended ASCII table ( 128 to 255 )
<script type="text/javascript">
document.write("<table>");
for(var i=128;i<=255;i++){
if( i%5 ==0){document.write ("</tr><tr>");}
document.write("<td>" + i + ' = '+String.fromCharCode(i) + "</td>");
}
document.write("</tr></table>");
</script>
Note : Direct output of all ASCII chars may not be visible in browser ( like Nul, space etc )

DEMO displaying ASCII ( above code )
charcodeat to get UTF-16 of the given index point
JavaScript String Reference Uppercase to lower case by toLowerCase() method
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer