T
terry
Anyone can give me an example? I know Java is able to do that.
Thanks!
Thanks!
Anyone can give me an example? I know Java is able to do that.
Gordon Beaton said:There seem to be several "GB" encodings like GBK, GB18030, x-EUC-CN
and ISO2022_CN_GB. You can see for yourself here:
http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html
Create an InputStreamReader and OutputStreamWriter, specifying
appropriate encodings for each, then simply copy your data from one to
the other:
// data source
InputStream is = ...
InputStreamReader isr = new InputStreamReader(is,"Big5");
BufferedReader br = new BufferedReader(isr);
// destination
OutputStream os = ...
OutputStreamWriter osw = new OutputStreamWriter(os,"GBK");
BufferedWriter bw = new BufferedWriter(osw);
String line;
while ((line = br.readLine()) != null) {
bw.write(line);
bw.newLine();
}
br.close();
bw.close();
/gordon
Anyone can give me an example? I know Java is able to do that.
Gordon Beaton said:There seem to be several "GB" encodings like GBK, GB18030, x-EUC-CN
and ISO2022_CN_GB. You can see for yourself here:
http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html
Create an InputStreamReader and OutputStreamWriter, specifying
appropriate encodings for each, then simply copy your data from one to
the other:
// data source
InputStream is = ...
InputStreamReader isr = new InputStreamReader(is,"Big5");
BufferedReader br = new BufferedReader(isr);
// destination
OutputStream os = ...
OutputStreamWriter osw = new OutputStreamWriter(os,"GBK");
BufferedWriter bw = new BufferedWriter(osw);
String line;
while ((line = br.readLine()) != null) {
bw.write(line);
bw.newLine();
}
br.close();
bw.close();
/gordon
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.