如何把ecside应用到utf-8的项目上去。
|
RomKK
2007-03-01
以前开发了一个项目采用的是utf8的编码,以前用的是extremecomponents,现在想把ecside替换了以前的extremecomponents,这样可行吗?要注意些什么呢?
同时也谢谢老大的辛勤劳动,提供这么好的一个东东。 |
|
|
bjwulin
2007-03-01
其实,大家自己可以写个程序将gb2312的编码文件转成utf-8,反正我每次都转换一次,没有任何问题。
编码不是使用的障碍。ecside做的确实很不错。 |
|
|
fins
2007-03-01
我一直没有做utf-8版本 对不起大家了
原因以前说过的 我暂时不能同时维护多个版本. 有机会一定弄一个 bjwulin 你通常是怎么转换的呢? 写了一个程序? 能不能把那个程序 share一下 谢谢了 |
|
|
bjwulin
2007-03-01
好的,写的不好,大家多批评:
public class FileEncodeChange {
public static void changeFileEncode(File file, String sourceEncode, String targetEncode) {
if (file.isDirectory()) {
File subDictoriesOrFiles[] = file.listFiles();
for (int i = 0; i < subDictoriesOrFiles.length; i++) {
changeFileEncode(subDictoriesOrFiles[i], sourceEncode, targetEncode);
}
} else {
String filePath = file.getPath();
String tmpFilePath = "";
if (filePath.lastIndexOf(".") != -1) {
tmpFilePath = filePath.substring(0, filePath.lastIndexOf(".")) + "_utftmp" + filePath.substring(filePath.lastIndexOf("."));
} else {
tmpFilePath = filePath + "_utftmp";
}
try {
FileInputStream fin = new FileInputStream(file);
BufferedReader bfReader = new BufferedReader(new InputStreamReader(fin, sourceEncode));
FileOutputStream fout = new FileOutputStream(tmpFilePath);
BufferedWriter bfWriter = new BufferedWriter(new OutputStreamWriter(fout, targetEncode));
String str;
while ((str = bfReader.readLine()) != null) {
System.out.println(str);
bfWriter.write(str);
bfWriter.newLine();
}
bfReader.close();
fin.close();
bfWriter.close();
fout.close();
// 删除旧文件
file.delete();
// 重命名新文件
File newFile = new File(tmpFilePath);
newFile.renameTo(new File(filePath));
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static void gbk2utf(File file) {
changeFileEncode(file, "GB2312", "utf8");
}
public static void gbk2utf(String filePath) {
gbk2utf(new File(filePath));
}
public static void main(String[] args)
{
gbk2utf("c:/sss.txt");
}
}
|

