punycode#
Stability: 2 - Unstable
Punycode.js is bundled with Node.js v0.6.2+. Use
require('punycode')
to access it. (To use it with other Node.js versions,
use npm to install the punycode
module first.)
Stability: 2 - Unstable Punycode.js 는 Node.js v0.6.2+부터 포함되었고
require('punycode')
로 접근한다.(다른 Node.js 버전에서 이 모듈을 사용하려면
npm으로 punycode
모듈을 설치해야 한다.)
punycode.decode(string)#
Converts a Punycode string of ASCII code points to a string of Unicode code
points.
// decode domain name parts
punycode.decode('maana-pta'); // 'mañana'
punycode.decode('--dqo34k'); // '☃-⌘'
ASCII 코드의 퓨니코드(Punycode) 문자열을 유니코드 문자열로 변환한다.
// 도메인 명 부분을 디코드한다
punycode.decode('maana-pta'); // 'mañana'
punycode.decode('--dqo34k'); // '☃-⌘'
punycode.encode(string)#
Converts a string of Unicode code points to a Punycode string of ASCII code
points.
// encode domain name parts
punycode.encode('mañana'); // 'maana-pta'
punycode.encode('☃-⌘'); // '--dqo34k'
유니코드 문자열을 ASCII 코드의 퓨니코드(Punycode) 문자열로 변환한다.
// 도메인명 부분을 인코딩한다
punycode.encode('mañana'); // 'maana-pta'
punycode.encode('☃-⌘'); // '--dqo34k'
punycode.toUnicode(domain)#
Converts a Punycode string representing a domain name to Unicode. Only the
Punycoded parts of the domain name will be converted, i.e. it doesn't matter if
you call it on a string that has already been converted to Unicode.
// decode domain names
punycode.toUnicode('xn--maana-pta.com'); // 'mañana.com'
punycode.toUnicode('xn----dqo34k.com'); // '☃-⌘.com'
도메인 명을 나타내는 퓨니코드 문자열을 유니코드로 변환한다. 도메인 명에서 퓨니코드부분만
변환된다. 예를 들어 이미 유니코드로 변환된 문자열에서 이 함수를 호출해도 아무 문제가 없다.
// 도메인 명을 디코드한다
punycode.toUnicode('xn--maana-pta.com'); // 'mañana.com'
punycode.toUnicode('xn----dqo34k.com'); // '☃-⌘.com'
punycode.toASCII(domain)#
Converts a Unicode string representing a domain name to Punycode. Only the
non-ASCII parts of the domain name will be converted, i.e. it doesn't matter if
you call it with a domain that's already in ASCII.
// encode domain names
punycode.toASCII('mañana.com'); // 'xn--maana-pta.com'
punycode.toASCII('☃-⌘.com'); // 'xn----dqo34k.com'
도메인 명을 나타내는 유니코드 문자열을 퓨니코드로 변환한다. 도메인 명에서 ASCII가 아닌
부분만 변환한다. 이미 ASCII인 도메인에서 호출해도 괜찮다.
// 도메인 명을 인코딩한다
punycode.toASCII('mañana.com'); // 'xn--maana-pta.com'
punycode.toASCII('☃-⌘.com'); // 'xn----dqo34k.com'
punycode.ucs2#
punycode.ucs2.decode(string)#
Creates an array containing the decimal code points of each Unicode character
in the string. While JavaScript uses UCS-2
internally , this function
will convert a pair of surrogate halves (each of which UCS-2 exposes as
separate characters) into a single code point, matching UTF-16.
punycode.ucs2.decode('abc'); // [97, 98, 99]
// surrogate pair for U+1D306 tetragram for centre:
punycode.ucs2.decode('\uD834\uDF06'); // [0x1D306]
문자열의 각 유니코드 문자에 대한 십진수 코드를 담고 있는 배열을 생성한다. JavaScript
가 내부적으로 UCS-2를 사용하기 때문에
이 함수는 서로게이트 반쪽(surrogate halves)의 쌍을(UCS-2의 각각은 분리된 코드로 나타난다)
UTF-16에 맞는 단일 코드로 변환한다.
punycode.ucs2.decode('abc'); // [97, 98, 99]
// surrogate pair for U+1D306 tetragram for centre:
punycode.ucs2.decode('\uD834\uDF06'); // [0x1D306]
punycode.ucs2.encode(codePoints)#
Creates a string based on an array of decimal code points.
punycode.ucs2.encode([97, 98, 99]); // 'abc'
punycode.ucs2.encode([0x1D306]); // '\uD834\uDF06'
십진수코드 배열에 기반을 둔 문자열을 생성한다.
punycode.ucs2.encode([97, 98, 99]); // 'abc'
punycode.ucs2.encode([0x1D306]); // '\uD834\uDF06'
punycode.version#
현재 Punycode.js 버전번호를 나타내는 문자열.