From Charcode is a string method {fromCharCode()
method} in JavaScript, which is used to convert the Unicode values to the characters. The parameter/parameters to the fromCharCode()
method is one or more unicode values.
In JavaScript, by using fromCharCode()
we can convert the Unicode value into character.
<p>Click on the "Button" to convert the Unicode into a character.</p> <input type="button" value="Convert" onclick="Function()"/> <p id="myId"></p> <script> function Function() { var res = String.fromCharCode(100) document.getElementById("myId").innerHTML = res; } </script>
In the above code snippet we have given ID
as "myId" to the second <p>
element, we have given the Unicode value 100 to the fromCharCode()
method, there is a button with value "Convert" in the HTML code. Onclick of the button fires the Function() in the <script>
code and the fromCharCode()
convert the Unicode to character.
OUTPUT
<p>Click on the "Button" to convert the Unicode values into characters.</p> <input type="button" value="Convert" onclick="Function()"/> <p id="myId"></p> <script> function Function() { var res = String.fromCharCode(84, 69, 67, 72, 70, 85, 78, 68, 65); document.getElementById("myId").innerHTML = res; } </script>
Converting unicode values to characters
We need to convert the unicode values to the characters, for that we are using fromCharCode()
method. Onclick of the button converts the unicode values to the characters and returns the output.
OUTPUT
Views: 45427 | Post Order: 70