├── .gitattributes ├── .gitignore ├── Encode.cpp ├── Encode.h ├── Filetool.cpp ├── Filetool.h ├── README ├── Stringtool.cpp ├── Stringtool.h ├── encodeconv.cpp ├── encodeconv.sln ├── encodeconv.vcxproj ├── encodeconv.vcxproj.filters ├── stdafx.cpp ├── stdafx.h ├── targetver.h └── test ├── dotest.bat ├── encodeconv.exe └── test.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | 46 | [Dd]ebug/ 47 | [Rr]elease/ 48 | x64/ 49 | build/ 50 | [Bb]in/ 51 | [Oo]bj/ 52 | 53 | # MSTest test Results 54 | [Tt]est[Rr]esult*/ 55 | [Bb]uild[Ll]og.* 56 | 57 | *_i.c 58 | *_p.c 59 | *.ilk 60 | *.meta 61 | *.obj 62 | *.pch 63 | *.pdb 64 | *.pgc 65 | *.pgd 66 | *.rsp 67 | *.sbr 68 | *.tlb 69 | *.tli 70 | *.tlh 71 | *.tmp 72 | *.tmp_proj 73 | *.log 74 | *.vspscc 75 | *.vssscc 76 | .builds 77 | *.pidb 78 | *.log 79 | *.scc 80 | 81 | # Visual C++ cache files 82 | ipch/ 83 | *.aps 84 | *.ncb 85 | *.opensdf 86 | *.sdf 87 | *.cachefile 88 | 89 | # Visual Studio profiler 90 | *.psess 91 | *.vsp 92 | *.vspx 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | 101 | # TeamCity is a build add-in 102 | _TeamCity* 103 | 104 | # DotCover is a Code Coverage Tool 105 | *.dotCover 106 | 107 | # NCrunch 108 | *.ncrunch* 109 | .*crunch*.local.xml 110 | 111 | # Installshield output folder 112 | [Ee]xpress/ 113 | 114 | # DocProject is a documentation generator add-in 115 | DocProject/buildhelp/ 116 | DocProject/Help/*.HxT 117 | DocProject/Help/*.HxC 118 | DocProject/Help/*.hhc 119 | DocProject/Help/*.hhk 120 | DocProject/Help/*.hhp 121 | DocProject/Help/Html2 122 | DocProject/Help/html 123 | 124 | # Click-Once directory 125 | publish/ 126 | 127 | # Publish Web Output 128 | *.Publish.xml 129 | *.pubxml 130 | 131 | # NuGet Packages Directory 132 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 133 | #packages/ 134 | 135 | # Windows Azure Build Output 136 | csx 137 | *.build.csdef 138 | 139 | # Windows Store app package directory 140 | AppPackages/ 141 | 142 | # Others 143 | sql/ 144 | *.Cache 145 | ClientBin/ 146 | [Ss]tyle[Cc]op.* 147 | ~$* 148 | *~ 149 | *.dbmdl 150 | *.[Pp]ublish.xml 151 | *.pfx 152 | *.publishsettings 153 | 154 | # RIA/Silverlight projects 155 | Generated_Code/ 156 | 157 | # Backup & report files from converting an old project file to a newer 158 | # Visual Studio version. Backup files are not needed, because we have git ;-) 159 | _UpgradeReport_Files/ 160 | Backup*/ 161 | UpgradeLog*.XML 162 | UpgradeLog*.htm 163 | 164 | # SQL Server files 165 | App_Data/*.mdf 166 | App_Data/*.ldf 167 | 168 | ############# 169 | ## Windows detritus 170 | ############# 171 | 172 | # Windows image file caches 173 | Thumbs.db 174 | ehthumbs.db 175 | 176 | # Folder config file 177 | Desktop.ini 178 | 179 | # Recycle Bin used on file shares 180 | $RECYCLE.BIN/ 181 | 182 | # Mac crap 183 | .DS_Store 184 | 185 | .svn/ 186 | 187 | ############# 188 | ## Python 189 | ############# 190 | 191 | *.py[co] 192 | 193 | # Packages 194 | *.egg 195 | *.egg-info 196 | dist/ 197 | build/ 198 | eggs/ 199 | parts/ 200 | var/ 201 | sdist/ 202 | develop-eggs/ 203 | .installed.cfg 204 | 205 | # Installer logs 206 | pip-log.txt 207 | 208 | # Unit test / coverage reports 209 | .coverage 210 | .tox 211 | 212 | #Translations 213 | *.mo 214 | 215 | #Mr Developer 216 | .mr.developer.cfg 217 | -------------------------------------------------------------------------------- /Encode.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Encode.h" 3 | #include "Stringtool.h" 4 | #include "Filetool.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | 13 | namespace Lazy 14 | { 15 | 16 | const std::wstring & cpToCode(size_t cp) 17 | { 18 | if(cp == CP::utf7) return Encode::utf7; 19 | else if(cp == CP::utf8) return Encode::utf8; 20 | else if(cp == CP::gbk) return Encode::gbk; 21 | else if(cp == CP::big5) return Encode::big5; 22 | else if(cp == CP::ucs_2le) return Encode::ucs_2le; 23 | else if(cp == CP::ucs_2be) return Encode::ucs_2be; 24 | else if(cp == CP::ucs2) return Encode::ucs2; 25 | else return Encode::none; 26 | } 27 | 28 | size_t codeToCp(const std::wstring & code) 29 | { 30 | if(code == Encode::utf7) return CP::utf7; 31 | else if(code == Encode::utf8) return CP::utf8; 32 | else if(code == Encode::gbk) return CP::gbk; 33 | else if(code == Encode::big5) return CP::big5; 34 | else if(code == Encode::ucs_2le) return CP::ucs_2le; 35 | else if(code == Encode::ucs_2be) return CP::ucs_2be; 36 | else if(code == Encode::ucs2) return CP::ucs2; 37 | else return CP::none; 38 | } 39 | 40 | bool charToWChar(std::wstring & dest, const std::string & str, size_t code) 41 | { 42 | int lLen = MultiByteToWideChar(code, 0, str.c_str(), -1, NULL, 0); 43 | 44 | dest.resize(lLen, 0); 45 | 46 | lLen = MultiByteToWideChar(code, 0, str.c_str(), -1, &dest[0], lLen); 47 | if(lLen <= 0) return false; 48 | 49 | dest.erase(lLen - 1); 50 | return true; 51 | } 52 | 53 | bool wcharToChar(std::string & dest, const std::wstring & wstr, size_t code) 54 | { 55 | int lLen = WideCharToMultiByte(code, 0, wstr.c_str(), -1, NULL, 0, NULL, NULL); 56 | dest.resize(lLen); 57 | 58 | lLen = WideCharToMultiByte(code, 0, wstr.c_str(), -1, &dest[0], lLen, NULL, NULL); 59 | if(lLen <= 0) return false; 60 | 61 | dest.erase(lLen - 1); 62 | return true; 63 | } 64 | 65 | bool cmpEncodeMark(const char *eMark, const char *mark) 66 | { 67 | assert(eMark && mark); 68 | 69 | int i = 0; 70 | while(eMark[i] != 0) 71 | { 72 | if(0 == mark[i]) return false; 73 | if(eMark[i] != mark[i]) return false; 74 | 75 | ++i; 76 | } 77 | 78 | return true; 79 | } 80 | 81 | size_t readString(std::wstring & dest, FILE *pFile, size_t codePage) 82 | { 83 | assert(pFile && "readString"); 84 | 85 | long curFPos = ftell(pFile); 86 | 87 | //尝试读取文件编码头 88 | char mark[EncodeMark::maxMarkLen+1]; 89 | fread(mark, EncodeMark::maxMarkLen, 1, pFile); 90 | fseek(pFile, curFPos, SEEK_SET); 91 | 92 | //优先使用文件编码头 93 | if(cmpEncodeMark(EncodeMark::utf8, mark)) 94 | { 95 | codePage = CP::utf8; 96 | fseek(pFile, strlen(EncodeMark::utf8), SEEK_CUR); 97 | } 98 | else if(cmpEncodeMark(EncodeMark::ucs_2le, mark)) 99 | { 100 | codePage = CP::ucs_2le; 101 | fseek(pFile, strlen(EncodeMark::ucs_2le), SEEK_CUR); 102 | } 103 | else if(cmpEncodeMark(EncodeMark::ucs_2be, mark)) 104 | { 105 | codePage = CP::ucs_2be; 106 | fseek(pFile, strlen(EncodeMark::ucs_2be), SEEK_CUR); 107 | } 108 | 109 | dest.clear(); 110 | const long length = seekFileLength(pFile); 111 | if(length == 0)return Error::ok; 112 | 113 | if(codePage == CP::ucs_2le) 114 | { 115 | size_t n = (length + 1) / 2; 116 | dest.resize(n); 117 | n = fread(&dest[0], 2, n, pFile); 118 | dest.erase(n); 119 | 120 | if(n == 0) return Error::readFile; 121 | } 122 | else if(codePage == CP::ucs_2be) 123 | { 124 | std::string buffer(length, 0); 125 | size_t n = fread(&buffer[0], 1, length, pFile); 126 | buffer.erase(n); 127 | 128 | if(n == 0) return Error::readFile; 129 | 130 | wchar_t ch; 131 | size_t ulen = n / 2; 132 | dest.resize(ulen); 133 | for(size_t i=0; i> 8) & 0xff; 181 | buffer[i*2 + 1] = ch & 0xff; 182 | } 183 | 184 | if(fwrite(&buffer[0], 1, buffer.size(), pFile) != buffer.size()) 185 | return Error::writeFile; 186 | } 187 | else 188 | { 189 | //写入编码头 190 | if(bom && codePage==CP::utf8) 191 | { 192 | fwrite(EncodeMark::utf8, 1, strlen(EncodeMark::utf8), pFile); 193 | } 194 | 195 | std::string buffer; 196 | if(!wcharToChar(buffer, src, codePage)) 197 | return Error::encodeFailed; 198 | 199 | if(fwrite(&buffer[0], 1, buffer.size(), pFile) != buffer.size()) 200 | return Error::writeFile; 201 | } 202 | 203 | return Error::ok; 204 | } 205 | 206 | size_t convertFile(const std::wstring & destFile, 207 | const std::wstring & destEncode, 208 | const std::wstring & srcFile, 209 | const std::wstring & srcEncode, 210 | bool useBom) 211 | { 212 | size_t srcCP = codeToCp(srcEncode); 213 | size_t destCP = codeToCp(destEncode); 214 | 215 | if(destCP == CP::none) return Error::invalidEncode; 216 | 217 | std::wstring buffer; 218 | 219 | { 220 | FILE* pFile = openFile(srcFile, L"rb"); 221 | if(pFile == nullptr) 222 | return Error::open; 223 | 224 | size_t result = readString(buffer, pFile, srcCP); 225 | fclose(pFile); 226 | 227 | if(result != Error::ok) return result; 228 | } 229 | 230 | { 231 | FILE *pFile = openFile(destFile, L"wb"); 232 | if(pFile == nullptr) 233 | return Error::open; 234 | 235 | size_t result = writeString(buffer, pFile, destCP, useBom); 236 | fclose(pFile); 237 | 238 | if(result != Error::ok) return result; 239 | } 240 | 241 | return Error::ok; 242 | } 243 | 244 | size_t _convertPath(const std::wstring & destPath, 245 | const std::wstring & destEncode, 246 | const std::wstring & srcPath, 247 | const std::wstring & srcEncode, 248 | bool useBom, 249 | const StringArray & filter, 250 | bool rescursively) 251 | { 252 | std::wcout< 4 | 5 | namespace Lazy 6 | { 7 | ///编码描述 8 | namespace Encode 9 | { 10 | const std::wstring none = L""; 11 | const std::wstring gbk = L"gbk"; 12 | const std::wstring big5 = L"big5"; 13 | const std::wstring utf7 = L"utf-7"; 14 | const std::wstring utf8 = L"utf-8"; 15 | const std::wstring ucs2 = L"ucs2"; 16 | const std::wstring ucs_2le = L"ucs-2le"; 17 | const std::wstring ucs_2be = L"ucs-2be"; 18 | } 19 | 20 | ///code page.代码页 21 | namespace CP 22 | { 23 | const size_t none = 0; 24 | const size_t gbk = 936; 25 | const size_t big5 = 950; 26 | const size_t utf7 = 65000; 27 | const size_t utf8 = 65001; 28 | const size_t ucs_2le = 1200; 29 | const size_t ucs_2be = 1201; 30 | const size_t ucs2 = ucs_2le; 31 | } 32 | 33 | ///编码标志 34 | namespace EncodeMark 35 | { 36 | const char ucs_2le[] = "\xFF\xFE"; 37 | const char ucs_2be[] = "\xFE\xFF"; 38 | const char utf8[] = "\xEF\xBB\xBF"; 39 | const size_t maxMarkLen = 4; 40 | } 41 | 42 | ///错误编码 43 | namespace Error 44 | { 45 | const size_t ok = 0;///<没有错误 46 | const size_t encodeFailed = 1;///<编码(转成多字节)失败 47 | const size_t decodeFailed = 2;///<解码(转成unicode)失败 48 | const size_t open = 3;///<打开文件失败 49 | const size_t readFile = 4;///<读取文件失败 50 | const size_t writeFile = 5;///<写入文件失败 51 | const size_t invalidEncode = 6;///<无效的编码 52 | const size_t invalidFilter = 7;///<无效的过滤器 53 | const size_t searchFailed = 8;///<搜索文件失败 54 | const size_t mkdir = 9;///<创建文件夹 55 | } 56 | 57 | ///编码描述转换到编码页 58 | const std::wstring & cpToCode(size_t cp); 59 | 60 | ///编码页转换到编码描述 61 | size_t codeToCp(const std::wstring & code); 62 | 63 | 64 | ///窄字符转换到宽字符 65 | bool charToWChar(std::wstring & dest, const std::string & str, size_t code); 66 | 67 | ///宽字符转换到窄字符 68 | bool wcharToChar(std::string & dest, const std::wstring & wstr, size_t code); 69 | 70 | 71 | ///用指定编码读取出字符串 72 | size_t readString(std::wstring & dest, FILE *pFile, size_t codePage); 73 | 74 | ///用指定编码写入字符串 75 | size_t writeString(const std::wstring & src, FILE *pFile, size_t codePage, bool bom); 76 | 77 | 78 | ///转换文件编码 79 | size_t convertFile(const std::wstring & destFile, 80 | const std::wstring & destEncode, 81 | const std::wstring & srcFile, 82 | const std::wstring & srcEncode, 83 | bool useBom); 84 | 85 | ///转换目录中所有文件的编码 86 | ///注意:递归模式下,destPath不能为srcPath的子目录。当然两者可以相等。 87 | size_t convertPath(const std::wstring & destPath, 88 | const std::wstring & destEncode, 89 | const std::wstring & srcPath, 90 | const std::wstring & srcEncode, 91 | bool useBom, 92 | const std::wstring & filter, 93 | bool rescursively); 94 | 95 | }//end namespace Lazy -------------------------------------------------------------------------------- /Filetool.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Filetool.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | namespace Lazy 11 | { 12 | 13 | FILE* openFile(const std::wstring & fname, const std::wstring & mode) 14 | { 15 | FILE *pFile; 16 | errno_t eno = _wfopen_s(&pFile, fname.c_str(), mode.c_str()); 17 | if(eno == 0) return pFile; 18 | 19 | #ifdef LAZY_DEBUG_MSG 20 | std::wcout< 4 | #include 5 | 6 | #define LAZY_DEBUG_MSG 7 | 8 | namespace Lazy 9 | { 10 | 11 | typedef std::vector StringArray; 12 | 13 | ///分隔字符串 14 | void splitstring(StringArray & out, const std::wstring & str, wchar_t ch); 15 | } 16 | 17 | -------------------------------------------------------------------------------- /encodeconv.cpp: -------------------------------------------------------------------------------- 1 | // encodeconv.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "Encode.h" 6 | 7 | #include 8 | 9 | 10 | std::wstring usage = \ 11 | L"encodeconv -f fname -s src encode [-d][dest encode] [-o][output file] [-nb]\n" 12 | L"encodeconv -p path -e extensions -s src encode [-d][dest encode] [-o][output path] [-r] [-nb]\n\n" 13 | L"-e: extension of target files. eg. txt;h;cpp\n" 14 | L"-s: the source file encode. eg. gbk\n" 15 | L"-d: the dest file encode. default is utf-8\n" 16 | L"-o: the output file or path. default is same as the input file or path.\n" 17 | L"-r: convert rescursively.\n" 18 | L"-nb: don't add bom.\n\n" 19 | L"eg. convert a file: encodeconv -f test.txt -s gbk -d utf-8 -o test2.txt\n" 20 | L"eg. convert files in path: encodeconv -p c:/test/ -e txt;h;cpp -s gbk -d utf-8 -o d:/test/ \n" 21 | ; 22 | 23 | ///查找参数名称 24 | int findArgN(const wchar_t *cmd, int argc, wchar_t* argv[]) 25 | { 26 | for(int i=1; i= argc) return -1; 41 | 42 | return index; 43 | } 44 | 45 | int wmain(int argc, wchar_t* argv[]) 46 | { 47 | if(argc < 3) 48 | { 49 | std::wcout<< usage <= 0) destName = argv[index]; 76 | else destName = srcName; 77 | 78 | //find src file encode. 79 | std::wstring srcEncode; 80 | index = findArgV(L"-s", argc, argv); 81 | if(index < 0) 82 | { 83 | std::wcout << "please input the source encoding with '-r encoding'!" << std::endl; 84 | return 0; 85 | } 86 | srcEncode = argv[index]; 87 | 88 | //find dest file encode. 89 | std::wstring destEncode = L"utf-8"; 90 | index = findArgV(L"-d", argc, argv); 91 | if(index >= 0) 92 | { 93 | destEncode = argv[index]; 94 | } 95 | 96 | bool rescursively = false; 97 | if(findArgN(L"-r", argc, argv) >= 0) 98 | { 99 | rescursively = true; 100 | } 101 | 102 | bool useBom = true; 103 | if(findArgN(L"-nb", argc, argv) >= 0) 104 | { 105 | useBom = false; 106 | } 107 | 108 | size_t result; 109 | if(isForFile) 110 | { 111 | 112 | #ifdef LAZY_DEBUG_MSG 113 | std::wcout< 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {2AAF81AA-5D31-4877-B6D2-2367C9525D34} 15 | Win32Proj 16 | encodeconv 17 | 18 | 19 | 20 | Application 21 | true 22 | Unicode 23 | 24 | 25 | Application 26 | false 27 | true 28 | Unicode 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | true 42 | 43 | 44 | false 45 | 46 | 47 | 48 | Use 49 | Level3 50 | Disabled 51 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | 53 | 54 | Console 55 | true 56 | 57 | 58 | 59 | 60 | Level3 61 | Use 62 | MaxSpeed 63 | true 64 | true 65 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 66 | 67 | 68 | Console 69 | true 70 | true 71 | true 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | Create 90 | Create 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /encodeconv.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | Source Files 46 | 47 | 48 | Source Files 49 | 50 | 51 | Source Files 52 | 53 | 54 | -------------------------------------------------------------------------------- /stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // encodeconv.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /test/dotest.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | ::gbk to utf-8. same as: encodeconv -f test.txt -o test_utf8.txt -s gbk -d utf-8 4 | encodeconv -f test.txt -s gbk -o test_utf8.txt 5 | 6 | ::gbk to utf-8 no bom 7 | encodeconv -f test.txt -s gbk -o test_utf8_nb.txt -nb 8 | 9 | ::utf-8 to ucs2 10 | encodeconv -f test_utf8.txt -s gbk -d ucs2 -o test_ucs2.txt 11 | 12 | ::utf-8 to ucs-2be 13 | encodeconv -f test_utf8.txt -s gbk -d ucs-2be -o test_ucs_2be.txt 14 | 15 | ::ucs2 to utf-8 16 | encodeconv -f test_ucs2.txt -s gbk -d utf-8 -o test_ucs2_utf8.txt 17 | 18 | ::ucs-2be to utf-8 19 | encodeconv -f test_ucs_2be.txt -s gbk -d utf-8 -o test_ucs_2be_utf8.txt 20 | 21 | @pause 22 | -------------------------------------------------------------------------------- /test/encodeconv.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/youlanhai/encodeconv/8a078e043746dde0154e95a70c1330c5c0381fae/test/encodeconv.exe -------------------------------------------------------------------------------- /test/test.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/youlanhai/encodeconv/8a078e043746dde0154e95a70c1330c5c0381fae/test/test.txt --------------------------------------------------------------------------------