• 请不要在回答技术问题时复制粘贴 AI 生成的内容
MrEatChicken
V2EX  ›  程序员

请教,有没有工具能将 GB2312 的代码文件转 UTF8

  •  
  •   MrEatChicken · Feb 28, 2022 · 3930 views
    This topic created in 1724 days ago, the information mentioned may be changed or developed.

    试了下直接转编码格式,中文会乱码 有没有工具可以统一转下,中文也能正常显示。 谢谢各位

    12 replies  •  2022-03-04 16:13:20 +08:00
    cooleggs
    cooleggs
    Feb 28, 2022
    1
    vscode 不就可以么,so easy
    BrettD
    BrettD
    Feb 28, 2022 via iPhone❤️1
    2
    iconv
    knightdf
    knightdf
    Feb 28, 2022❤️1
    3
    iconv +1
    unishare
    unishare
    Feb 28, 2022
    4
    有可以批量转的吗
    likeunix
    likeunix
    Feb 28, 2022
    5
    Ctrl+C and Ctrl+V
    jim9606
    jim9606
    Feb 28, 2022❤️1
    6
    命令行 iconv ,支持任意方向的编码转码。
    xuanbg
    xuanbg
    Feb 28, 2022
    7
    vscode 可以用 GB2312 编码打开,然后保存为任意编码
    AllenHua
    AllenHua
    Feb 28, 2022
    8
    啊这,np++ 也可
    imn1
    imn1
    Feb 28, 2022
    9
    单文件现代编辑器基本都可以,打开再同名另存选编码就行
    批量的也有不少工具,搜搜就见到
    shawndev
    shawndev
    Feb 28, 2022
    10
    iconv
    MrEatChicken
    MrEatChicken
    OP
    Feb 28, 2022❤️1
    11
    感谢各位,已经用 iconv 了,写了个 shell 脚本
    有需要的可以拿去用

    #! /bin/bash
    function read_dir(){

    #iconv *.h -f GB2312 -t UTF-8 -o *.h
    for file in `ls $1` #注意此处这是两个反引号,表示运行系统命令
    do
    if [ -d $1"/"$file ] #注意此处之间一定要加上空格,否则会报错
    then
    echo menu $1"/"$file
    read_dir $1"/"$file
    else
    if [ "${file##*.}"x = "h"x ]||[ "${file##*.}"x = "cpp"x ];then #只转.h 和.cpp 的文件
    iconv $1"/"$file -f GB2312 -t UTF-8 -o $1"/"$file #GB2312 转换 UTF-8
    echo $1"/"$file
    fi
    fi
    done
    }
    #读取第一个参数
    read_dir $1
    dcncy
    dcncy
    Mar 4, 2022
    12
    @unishare 试试这个工具 UltraCodingSwitch ,非常强。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   919 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 21:05 · PVG 05:05 · LAX 13:05 · JFK 16:05
    ♥ Do have faith in what you're doing.