DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

将繁体汉字转换为简体


繁体汉字转换为简体包含了多种情况,比较简单的情形是源文件采用 BIG5 编码, 只要转换为 GB2312 编码就行了,既可以使用 Windows 上的 Notepad++,也可以用 Linux 上的 cconv。 如果繁体字采用 UTF-8 编码,Notepad++ 就无能为力了,只能用 cconv.

下面的代码首先分析一个繁体字幕文件 (inp.srt) 采用何种编码, 然后列出所有 cconv 支持的编码字符集,包括繁体字符集 UTF8-TW 和简体字符集 UTF8-CN,最后转换为简体汉字保存在文件 target.srt 中:

$ file inp.srt
inp.srt: UTF-8 Unicode (with BOM) text, with CRLF line terminators

$ sudo apt install cconv

$ cconv -l
The following encodings are supported:
Chinese:
   GB2312, GBK, GB-HANS, GB-HANT, GB18030, BIG5, UTF8, UTF8-CN, UTF8-TW, UTF8-HK
Other:
   All encoding supported by iconv.

$ cconv -f UTF8-TW -t UTF8-CN inp.srt -o target.srt

Note:

UTF-8 和 GBK 编码都同时包含简体和繁体汉字。



Published

Jan 2, 2019

Last Updated

Jan 2, 2019

Category

Tech

Tags

  • 编码 6
  • 汉字 3
  • 转换 11

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor