JavaScript / Object / String.fromCharCode() / 유니코드를 문자로 바꾸는 메서드
.fromCharCode()
.fromCharCode()는 유니코드를 문자로 바꾸는 메서드입니다.
문법
string.charCodeAt( index )
예제 1
'HELLO'.charCodeAt( 0 )
H의 유니코드 72를 반환합니다.
예제 2
<!doctype html> <html lang="ko"> <head> <meta charset="utf-8"> <title>JavaScript</title> <style> body { font-family: Consolas, monospace; } </style> </head> <body> <script> var jb = 'HELLO'; for ( i = 0; i < jb.length; i++ ) { document.write ( jb.charCodeAt( i ) + ' ' ); } </script> </body> </html>
반복문 for를 이용하여 문자열 전체의 유니코드를 출력합니다.