GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - stacksjs/ts-punycode: 🔃 A TypeScript Punycode converter. RFC 3492 & RFC 5891 supported.

BranchesTags
Open more actions menu

Latest commit

 

History

66 Commits
66 Commits

Folders and files

NameName
Last commit message
Last commit date
.config
.config
 
 
.github
.github
 
 
.vscode
.vscode
 
 
docs
docs
 
 
src
src
 
 
test
test
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CLAUDE.md
CLAUDE.md
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
buddy-bot.config.ts
buddy-bot.config.ts
 
 
build.ts
build.ts
 
 
bun.lock
bun.lock
 
 
bunfig.toml
bunfig.toml
 
 
clarity.config.ts
clarity.config.ts
 
 
deps.yaml
deps.yaml
 
 
package.json
package.json
 
 
pantry.lock
pantry.lock
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

Social Card of this repo

npm version GitHub Actions Commitizen friendly

ts-punycode

A modern TypeScript implementation of Punycode (RFC 3492) with full RFC 5891 support. This library helps you convert Unicode domain names to ASCII (Punycode) and back.

Features

  • 🔄 Bidirectional Conversion - Convert between Unicode and Punycode seamlessly
  • 📧 Email Support - Handles email addresses with Unicode domains
  • 💪 Type-Safe - Full TypeScript support with comprehensive type definitions
  • 🌐 RFC Compliant - Implements RFC 3492 and RFC 5891 specifications
  • 🧪 Well-Tested - Comprehensive test suite ensuring reliability
  • 📦 Zero Dependencies - Lightweight and self-contained
  • 🔍 Unicode 15.1 - Support for the latest Unicode standard

Installation

# Using npm
npm install ts-punycode

# Using yarn
yarn add ts-punycode

# Using pnpm
pnpm add ts-punycode

# Using bun
bun add ts-punycode

Usage

Basic Usage

import punycode from 'ts-punycode'

// Convert Unicode to Punycode
punycode.encode('münchen') // Returns 'mnchen-3ya'

// Convert Punycode to Unicode
punycode.decode('mnchen-3ya') // Returns 'münchen'

// Convert Domain Names
punycode.toASCII('münchen.de') // Returns 'xn--mnchen-3ya.de'
punycode.toUnicode('xn--mnchen-3ya.de') // Returns 'münchen.de'

// Handle Email Addresses
punycode.toASCII('user@münchen.de') // Returns '[email protected]'
punycode.toUnicode('[email protected]') // Returns 'user@münchen.de'

Advanced Usage

import punycode from 'ts-punycode'
// import { punycode } from 'ts-punycode'

// Working with Unicode Code Points
const codePoints = punycode.ucs2.decode('☃') // Returns [9731]
const string = punycode.ucs2.encode([9731]) // Returns '☃'

// Version Information
console.log(punycode.version) // Returns current version

API Reference

Main Methods

  • encode(input: string): string

    Converts a string of Unicode symbols to a Punycode string of ASCII-only symbols.

  • decode(input: string): string

    Converts a Punycode string of ASCII-only symbols to a string of Unicode symbols.

  • toASCII(input: string): string

    Converts a Unicode string representing a domain name or email address to Punycode.

  • toUnicode(input: string): string

    Converts a Punycode string representing a domain name or email address to Unicode.

UCS-2 Utilities

  • ucs2.decode(string: string): number[]

    Creates an array containing the numeric code points of each Unicode character.

  • ucs2.encode(codePoints: number[]): string

    Creates a string based on an array of numeric code points.

Error Handling

The library throws RangeError with descriptive messages for various error conditions:

  • Overflow: When input needs wider integers to process
  • Not Basic: When encountering illegal input >= 0x80 (not a basic code point)
  • Invalid Input: For general invalid input conditions

Contributing

Please see CONTRIBUTING for details.

Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discussions on GitHub

For casual chit-chat with others using this package:

Join the Stacks Discord Server

Postcardware

Stacks OSS will always stay open-sourced, and we will always love to receive postcards from wherever Stacks is used! And we also publish them on our website. Thank you, Spatie.

Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎

Credits

  • Mathias Bynens
  • Punycode.js
  • Chris Breuer

Sponsors

We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.

  • JetBrains
  • The Solana Foundation

License

The MIT License (MIT). Please see LICENSE for more information.

Made with 💙

About

🔃 A TypeScript Punycode converter. RFC 3492 & RFC 5891 supported.

ts-punycode.netlify.app

Topics

librarypunycoderfc-3492rfc-5891typescript

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

6 stars

Watchers

3 watching

Forks

1 fork
Report repository

Releases

Sponsor this project

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.