2010年9月10日 星期五

輸入簡體中文寫成csv檔,使用excel開啟顯示簡體

CFMX:
<cfcontent type="text/html; charset=UTF-8">
<cfif form.t_name neq "">
 <cfset csv_path="show/" >
 <cfset tmp_output ="浙江天台县今日通报发现天台县下路王村">

         <cfscript>
           writeFile = ("#csv_path#test_js3.csv");

           jFile = createobject("java", "java.io.File").init(writeFile);

           jStream = createobject("java", "java.io.FileOutputStream").init(jFile);

           jStream.write(239);

           jStream.write(187);

           jStream.write(191);

           jWriter = createobject("java", "java.io.OutputStreamWriter");

           jWriter.init(jStream, "UTF-8");

           jWriter.write(tmp_output);

           jWriter.flush();

           jWriter.close();

           jStream.close();

           </cfscript>

</cfif>
 =======================CF 5===================================

  <cftry>
   <cfset jStream=createobject("java","java.io.FileOutputStream")>
   <cfset jStream=jStream.init("show_u8.js")>
   <cfset jWriter=createobject("java","java.io.OutputStreamWriter")>
   <cfset jWriter=jWriter.init(jStream,"UTF-8")>
   <cfset a=jWriter.write(Chr(239))>
   <cfset a=jWriter.write(Chr(187))>
   <cfset a=jWriter.write(Chr(191))>
   <cfset a=jWriter.write(jstring)>
   <cfset a=jWriter.flush()>
   <cfset a=jWriter.close()>
   <cfset a=jStream.close()>
  <cfcatch></cfcatch>
  </cftry>

沒有留言:

張貼留言