puny-coder
v2.0.0
Published
Punycode converter.
Maintainers
Readme
Puny-coder
Punycode converter.
Representation of Unicode with the limited ASCII character subset.
Only Unicode and ASCII and vice versa converting.
🚀 Installation
npm install puny-coder🏗️ Examples
import { asciiToUnicode, unicodeToAscii } from "puny-coder";asciiToUnicode(text, onError, urlDecode)
import { asciiToUnicode } from "puny-coder";
declare function asciiToUnicode(
text: string,
onError?: string,
urlDecode?: boolean,
): string;| Parameter | Type | Description |
|:------------|:----------|:----------------------------------------|
| text | string | Required. Size in bytes. |
| onError | string | String that would be returned on error. |
| urlDecode | boolean | Additional decode URL. |
import { asciiToUnicode } from 'puny-coder';
asciiToUnicode("xn--%2C%20!-5cdkcjkOy7esao5p"); // "Здравей, свят!"
asciiToUnicode("xn--Ahoj%2C%20svte!-nsb"); // "Ahoj, světe!"
asciiToUnicode("xn--mxacd"); // "αβγ"
asciiToUnicode("xn--22cdfh1b8fsa"); // "ยจฆฟคฏข"
asciiToUnicode("xn--hq1bm8jm9l"); // "도메인"
asciiToUnicode("xn--eckwd4c7cu47r2wf"); // "ドメイン名例"asciiToUnicode(text, onError, urlDecode)
import { unicodeToAscii } from "puny-coder";
declare function unicodeToAscii(
text: string,
onError?: string,
urlEncode?: boolean,
skipOnValid?: boolean,
): string;| Parameter | Type | Description |
|:--------------|:----------|:----------------------------------------|
| text | string | Required. Size in bytes. |
| onError | string | String that would be returned on error. |
| urlEncode | boolean | Additional encode URL. |
| skipOnValid | boolean | Skip conversion on valid input. |
import { unicodeToAscii } from 'puny-coder';
unicodeToAscii("Здравей, свят!"); // "xn--%2C%20!-5cdkcjkOy7esao5p"
unicodeToAscii("Ahoj, světe!"); // "xn--Ahoj%2C%20svte!-nsb"
unicodeToAscii("αβγ"); // "xn--mxacd"
unicodeToAscii("ยจฆฟคฏข"); // "xn--22cdfh1b8fsa"
unicodeToAscii("도메인"); // "xn--hq1bm8jm9l"
unicodeToAscii("ドメイン名例"); // "xn--eckwd4c7cu47r2wf"