Unicode编码和区域编码有什么区别? unicode编码 unicode在线转码( 五 )



Unicode编码和区域编码有什么区别? unicode编码 unicode在线转码

文章插图
图 9. 缺少 BOM 标记乱码示例
清单 3. BOM 标记例子
private static void createCsvFile() {try {FileOutputStream fos = new FileOutputStream(&34;c:\\test.csv&34;);String str =&34;姓名,性别,年龄,出生年月&34;;fos.write(new byte[]{(byte)0xEF,(byte)0xBB, (byte)0xBF});OutputStreamWriter osw = new OutputStreamWriter(fos, &34;UTF-8&34;);BufferedWriter b_writer = new BufferedWriter(osw);b_writer.write(str);b_writer.close();} catch (IOException e) {System.out.println(e.toString());}}