Giter Site home page Giter Site logo

fileencoder's Introduction

转换文本编码,并进行正则替换

效果

测试文本 gbk.txt 编码为GB2312

STR("hello"), STR("world")
DDD("hello"), FFF("world")

输出结果 utf8.txt 编码为UTF8

MYSTR("hello"), MYSTR("world")
DDD("hello"), FFF("world")

编译

要求C++11,GCC4.9以上,MSVC为VS2013以上

依赖 Windows Linux
libiconv libiconv-win-build ./configure --host=x86_64-linux-gnu --prefix=/path/to/install --disable-shared --enable-static

将静态库(*.a或者*.lib)放置到lib目录下,include复制到include下。

Linux

mkdir build && cd build
cmake ..
make

Windows

md build && cd build
cmake ..
# 使用Visual Studio打开sln文件编译

运行

Linux

# 用shell会有美元转义,因此单引号
./FileEncoder gbk.txt utf8.txt gb2312 utf-8 '(STR)(\(\".*?\"\)):MYSTR$2'

Windows

# CMD: 没有美元转义,因此双引号,或者不用双引号
.\FileEncoder.exe gbk.txt utf8.txt gb2312 utf-8 "(STR)(\(\"".*?\""\)):MYSTR$2"

# PowerShell: 有美元转义,因此单引号
.\FileEncoder.exe gbk.txt utf8.txt gb2312 utf-8 '(STR)(\(\"".*?\""\)):MYSTR$2'

正则表达式替换不是必要的,可以省略该参数,只进行文件编码转换

./FileEncoder gbk.txt utf8.txt gb2312 utf-8

正则表达式替换可以先后进行多个,以逗号和分号间隔

# 先替换abc为xyz,再替换123为456
./FileEncoder gbk.txt utf8.txt gb2312 utf-8 'abc:xyz;123:456'

fileencoder's People

Contributors

lixingcong avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.