npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

chinese-telegraph-code

v0.1.0

Published

Chinese telegraph / commercial code (中文电码) lookup tables, sourced from the Unicode Unihan database.

Readme

chinese-telegraph-code

English | 简体中文

开源的中文电码(Chinese Telegraph Code / Chinese Commercial Code)查询数据表, 数据源自 Unicode Unihan 数据库。典型用途: 美签 DS-160 等表格里把中文姓名转成四位电码。

至今仍用于护照、签证(如 US DS-160 的 Chinese Commercial Code / Telecode 栏)、 港澳身份证件等。

数据表

| 文件 | 标准 | 字数 | Unihan 字段 | | ----------- | ---------- | ----- | -------------------- | | data/cn.* | 中国大陆 | 7,078 | kMainlandTelegraph | | data/tw.* | 台湾及香港 | 9,024 | kTaiwanTelegraph |

每张表都提供 CSV 与 JSON 两种格式。香港没有独立标准 —— HKID 与护照用的就是台湾这一脉的 电码,故 tw 台港通用。

格式

code,character,codepoint
0022,中,U+4E2D
[
  { "code": "0022", "character": "中", "codepoint": "U+4E2D" }
]

用法

import table from './data/cn.json' with { type: 'json' }

const codes = new Map(table.map(r => [r.character, r.code]))
const encode = name => [...name].map(c => codes.get(c) ?? '0000')

encode('张三') // ['1728', '0005']

表中查不到的字符(生僻字、标点)按惯例填 0000

构建

npm run build   # 重新下载 Unihan 并生成 data/

数据来源

源自 Unicode Unihan 数据库(v17.0.0)的 kMainlandTelegraphkTaiwanTelegraph 字段。大陆电码可追溯到邮电部《标准电码本》标准。

许可

代码采用 MIT。数据源自 Unicode Unihan,遵循 Unicode License