using System;
using SystemIO;
using SystemText;
using SystemRuntimeInteropServices;
//big繁体转换简体的程序
public class EncodeTool
{
[DllImport(kerneldll EntryPoint = LCMapStringA)]
public static extern int LCMapString(int Locale int dwMapFlags byte[] lpSrcStr int cchSrc byte[] lpDestStr int cchDest);
const int LCMAP_SIMPLIFIED_CHINESE = x;
const int LCMAP_TRADITIONAL_CHINESE = x;
public static void Main (String[] args)
{
if (argsLength<)
{
ConsoleWriteLine(请指定路径!);
}
String[] files=DirectoryGetFiles(args[]);
if(argsLength==)
files=DirectoryGetFiles(args[]args[]);
String dir=args[]+\\conv;
if(!DirectoryExists(dir)){
DirectoryCreateDirectory(dir);
}
for(int i=;i StreamReader sr = new StreamReader(files[i]EncodingGetEncoding(big));
String lines=srReadToEnd();
srClose();
lines=ConvertString(lines);
//ConsoleWriteLine(lines);
StreamWriter sw = new StreamWriter(dir+\\+files[i]falseEncodingGetEncoding(gb));
swWriteLine(lines);
swClose();
ConsoleWriteLine(转换 {} ok!files[i]);
}
}
public static String ConvertString(String lines){
Encoding gb = EncodingGetEncoding();
byte[] src=gbGetBytes(lines);
byte[] dest = new byte[srcLength];
LCMapString(x LCMAP_SIMPLIFIED_CHINESE src dest srcLength);
return gbGetString(dest);
}
}