You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求Python Unidecode库的JavaScript/TypeScript等效替代工具

类似Python Unidecode的JavaScript/TypeScript替代工具

以下是几个能实现Unicode转ASCII功能的JS/TS工具,适配不同需求:

  • unidecode-js
    这是专门对标Python Unidecode的库,逻辑和原库高度一致,支持绝大多数Unicode字符转码,包括特殊符号、带重音的拉丁字符,甚至能将中文字符转换为拼音。
    使用示例:

    // Node.js环境
    const unidecode = require('unidecode');
    console.log(unidecode('kožušček')); // 输出 'kozuscek'
    console.log(unidecode('30 \u{1d5c4}\u{1d5c6}/\u{1d5c1}')); // 输出 '30 km/h'
    console.log(unidecode('\u5317\u4EB0')); // 输出 'Bei Jing '
    

    TypeScript项目可直接安装使用,包内已包含类型定义文件。

  • lodash.deburr
    Lodash工具库中的deburr方法,专注于去除字符的重音标记,将带重音的Unicode拉丁字符转换为对应ASCII字符。缺点是对中文、特殊符号这类非拉丁字符的支持有限。
    使用示例:

    const _ = require('lodash');
    console.log(_.deburr('kožušček')); // 输出 'kozuscek'
    
  • iconv-lite
    偏向底层编码转换的库,需要手动指定编码格式,要实现类似Unidecode的效果需要额外处理逻辑,适合有特殊编码需求的场景。

内容的提问来源于stack exchange,提问作者Maciej Bledkowski

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 08:01:33