String.fromCharCode
String.fromCharCode()
๋ ์ ์ ๋ฉ์๋์ด๋ค.
UTF-16 ์ฝ๋ ๋จ์์ ์ํ์ค์์ stirng์ผ๋ก ๋ง๋ค์ด ๋ฐํํ๋ค.
String.fromCharCode(189, 43, 190, 61); // "ยฝ+ยพ="
์ ์ ๋ฉ์๋
ํด๋์ค์์ static
ํค์๋๋ฅผ ๋ถ์ฌ ๋ง๋ ๋ค.
dot notation์ผ๋ก ํธ์ถํ๊ณ , this๋ .(์ )์์๊ฐ ๋๋ค.
์ฌ๊ธฐ์ String
ํด๋์ค์ ์ธ์คํด์ค ์์ด ํธ์ถ์ด ๊ฐ๋ฅํ๋ค. ํด๋์ค๊ฐ ์ธ์คํด์คํ๋๋ฉด ํธ์ถํ ์ ์๋ค.
์ดํ๋ฆฌ์ผ์ด์ ์ ์ ํธ๋ฆฌํฐ ํจ์๋ฅผ ๋ง๋๋๋ฐ ์ฌ์ฉ๋๋ค.
Syntax
String.fromCharCode(num1, [,... [, numN ]])
Parameters
num1, ..., numN
UTF-16 ์ฝ๋ ๋จ์์ธ ์ซ์ ์ํ์ค, ๊ทธ ๋ฒ์๋ 0์์ 65535 (0xFFFF)๊น์ง์ด๋ค. 0xFFFF๋ณด๋ค ํฐ ์๋ ์๋ฅธ๋ค. ์ ํจ์ฑ ๊ฒ์ฌ๋ ์๋ค.
Return value
UTF-16 ์ฝ๋ ๋จ์๋ก ๊ตฌ์ฑ๋ N ๊ธธ์ด์ ๋ฌธ์์ด
Descripttion
์ด ๋ฉ์๋๋ String object๊ฐ ์๋ string์ ๋ฐํํ๋ค.
์๋ํ๋ฉด String
์ ์ ์ ๋ฉ์๋์ด๋ค. ์ง์ ์์ฑํ String object์ ๋ฉ์๋๊ฐ ์๋๋ผ, ํญ์ String.fromCharCode() ์ฌ์ฉํด์ผํ๋ค.
์๊ฐํด๋ณด๋.. String object๋ฅผ ๋ง๋ค ์ผ์ด ์์..
Examples
String.fromCharCode(65, 66, 67); // "ABC"
String.fromCharCode(0x2014); // "-"
String.fromCharCode(0x12014) // ์ซ์ 1์ ๋ฌด์ํ๋ค ์? "-" 0xFFFF๋ณด๋ค ํฐ ์๋ ์๋ฅธ๋ค.
๋ ํฐ ๊ฐ๊ณผ ์ฌ์ฉํ๊ธฐ
๋ชจ๋ ์ ํจํ ์ ๋์ฝ๋ ๊ฐ์ ์ฒ๋ฆฌํ๋ ค๋ฉด fromCharCode()๋ง์ผ๋ก ๋ถ์กฑํ๋ค.
๋ ๋์ ์ฝ๋ ํฌ์ธํธ ๋ฌธ์๋ ํ๋์ ๋ฌธ์๋ฅผ ํ์ฑํ๊ธฐ ์ํด ๋๊ฐ์ surrogate ๊ฐ ์ ์ฌ์ฉํ๋ค.
String.fromCodePoint()
์ ์ด์ฉํ์ฌ ๋์ ๊ฐ์ ๋ฌธ์๋ฅผ ํํํ๋ค.
Last updated
Was this helpful?