/ 工具
■/ 工具搜尋
109 款工具
/ Punycode 編碼/解碼器
/ 選定的工具
■Punycode 編碼/解碼器 - 免費 編碼與解碼 工具
為國際化網域名稱編碼與解碼 Punycode
■ 01
甚麼是 Punycode?
Punycode 是一種只使用網域名稱允許的有限 ASCII 子集(字母、數字與連字號)來表示 Unicode 字元的方式。它讓包含非 ASCII 字元的國際化網域名稱(IDN)得以…
■ 02
運作原理是甚麼?
ACE 前綴:Punycode 編碼的標籤以 ASCII Compatible Encoding(ACE)前綴 "xn--" 識別。例如德國城市「Munchen」在 Punycode 中變成「xn--mnchen-3ya」。編碼過程:ASCII 字元…
■ 03
範例情境
涵蓋德文網域、中文網域與日文網域,讓你能快速比較常見的輸入與輸出。
/ 相關工具
/ 程式碼
■選定工具的原始碼,與右側的即時版本並列顯示。
/ 原始碼
TypeScript
typescript
// Punycode encoding/decoding for internationalized domains
function toASCII(domain: string): string {
// Convert each label of the domain
return domain.split('.').map(label => {
// If already ASCII, return as-is
if (/^[\x00-\x7F]*$/.test(label)) {
return label;
}
// Otherwise encode with xn-- prefix