# 全角转半角

> 将全角的字母、数字、符号和空格转为半角，中文标点（如 ，！？）保持不变

版本：1.0.0 · 作者 Deck

- 安装到 Deck：deck://install-plugin?id=fullwidth-to-halfwidth&url=https%3A%2F%2Fgithub.com%2Fyuzeguitarist%2Fdeck-plugins%2Freleases%2Fdownload%2Fplugins%2Ffullwidth-to-halfwidth-1.0.0.zip
- 下载 .zip：https://github.com/yuzeguitarist/deck-plugins/releases/download/plugins/fullwidth-to-halfwidth-1.0.0.zip
- 在 GitHub 上查看：https://github.com/yuzeguitarist/deck-plugins/tree/main/plugins/fullwidth-to-halfwidth

也可以用终端安装：

```sh
mkdir -p ~/.deck/scripts/fullwidth-to-halfwidth && curl -fsSL https://github.com/yuzeguitarist/deck-plugins/releases/download/plugins/fullwidth-to-halfwidth-1.0.0.zip | tar -xf - -C ~/.deck/scripts/fullwidth-to-halfwidth
```

## 脚本

```js
// Turns full-width letters, digits and symbols into ASCII and the ideographic space into a space.
function transform(input) {
  // Full-width ! ( ) , : ; ? ~ stay: Chinese and Japanese text uses them as its own punctuation.
  const keep = "\uff01\uff08\uff09\uff0c\uff1a\uff1b\uff1f\uff5e";
  return String(input ?? "").replace(/[\u3000\uff01-\uff5e]/g, (char) => {
    if (char === "\u3000") return " ";
    return keep.includes(char) ? char : String.fromCharCode(char.charCodeAt(0) - 0xfee0);
  });
}
```

---

- HTML：https://deckclip.app/zh-cn/plugins/fullwidth-to-halfwidth
- English：https://deckclip.app/plugins/fullwidth-to-halfwidth.md

© 2026 潘禹泽
