ColdFusion,MS Word文档和希腊字符

我正在尝试从数据库动态构建Word文档(我正在使用CFC进行查询处理).我的努力很成功,但是我只能复制英语的文档.但是,我的应用程序使用希腊语.

当我尝试构建包含希腊字符的文档时,输出如下所示:??????????????????.我已经尝试了很多东西,但是没有任何效果.奇怪的是,当我使用同一CFC进行PDF复制时,希腊字符正确输出.

cfm文件:

<cfheader name="Content-Disposition" value="inline; filename=Save-Print.doc" charset="utf-8">
<cfcontent type="application/msword">

<html xmlns:o="urn:schemas-microsoft-com:office:office"
      xmlns:w="urn:schemas-microsoft-com:office:word" 
      xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Print</title>
<!--[if gte mso 9]> 
<xml>
<w:WordDocument>
<w:View>Print</w:View>
<w:Compatibility>
<w:UseAsianBreakRules/>
</w:Compatibility>
<w:Zoom>100</w:Zoom>
<w:DoNotOptimizeForBrowser/>
</w:WordDocument>
</xml>
<![endif]-->

<!--[if supportFields]>
<div style="mso-element:header" id="lala">
<p class=MsoHeader><span style="color:red">
<![endif]-->
<style>
<!--
@page Section1
{
size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;
mso-header-margin:.5in;
mso-footer-margin:.5in; 
mso-paper-source:0;
mso-header:url("http://localhost:8500/BookLedger_Final/resources/cfScripts/Header.html") h1;
mso-footer:url("http://localhost:8500/BookLedger_Final/resources/cfScripts/Header.html") f1;
}
div.Section1 {page:Section1;}
p.MsoHeader {
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #333;
}
p.MsoFooter {
}
-->
</style>
</head>

<body>

<cfif not IsDefined("URL.id")>
      <cfelseif not IsDefined("URL.model")>
</cfif>

  <!--- Get print details --->
  <cfinvoke
    component="Print"
    method="myPrint"
    returnvariable="getMember"
    id="#URL.id#" 
    model="#URL.model#">


    <div class=Section1>

      <cfoutput query="getMember">
        <b id="lala">#Title#</b>
        <p style="color:##1c1c1c"><i>#Body#</i></p>
      </cfoutput>      

    </div> 


</body>
</html>

cfc文件:

<cfcomponent>

    <cffunction name="myPrint" access="remote" returntype="query" output="no">

        <cfargument name="id" default="0" required="false" type="numeric">
        <cfargument name="model" default="" required="false" type="any">
        <cfset model = #ARGUMENTS.model#>

        <cfif model EQ "member">

        <cfquery name="getMember" datasource="rental">            
            SELECT CONCAT(rental.members.firstname,' ',rental.members.lastname) AS 'Title',rental.members.biog AS 'Body'
            FROM rental.members
            WHERE rental.members.id = #ARGUMENTS.id#
            AND rental.members.model = "#ARGUMENTS.model#"
        </cfquery>


        <!---<cfset queryToString = serializeJson(getMember)>
        <cfset strippedQuery = REReplace(queryToString,'<[^>]*>','','all')>--->

        <cfreturn getMember>



        <cfelseif model EQ "new_member">

        <cfquery name="getMember" datasource="rental">            
            SELECT CONCAT(rental.new_members.firstname,' ',rental.new_members.lastname) AS 'Title',rental.new_members.biog  AS 'Body' 
            FROM rental.new_members
            WHERE rental.new_members.id = #ARGUMENTS.id#
            AND rental.new_members.model = "#ARGUMENTS.model#"
        </cfquery>

        <cfreturn getMember>


        <cfelseif model EQ "book">

        <cfquery name="getMember" datasource="rental">            
            SELECT rental.books.title AS 'Title',rental.books.description AS 'Body'
            FROM rental.books
            WHERE rental.books.id = #ARGUMENTS.id#
            AND rental.books.model = "#ARGUMENTS.model#"
        </cfquery>

        <cfreturn getMember>


        <cfelseif model EQ "journal">

        <cfquery name="getMember" datasource="rental">            
            SELECT rental.journals.title AS 'Title',rental.journals.description AS 'Body'
            FROM rental.journals
            WHERE rental.journals.id = #ARGUMENTS.id#
            AND rental.journals.model = "#ARGUMENTS.model#"
        </cfquery>

        <cfreturn getMember>


        <cfelseif model EQ "cd">

        <cfquery name="getMember" datasource="rental">            
            SELECT rental.cd.title AS 'Title',rental.cd.description AS 'Body'
            FROM rental.cd
            WHERE rental.cd.id = #ARGUMENTS.id#
            AND rental.cd.model = "#ARGUMENTS.model#"
        </cfquery>

        <cfreturn getMember>

        </cfif>

    </cffunction>

</cfcomponent>
最佳答案
当我尝试您的pastebin示例时,我也变得很乱.好像您删除了< meta>指定utf-8的代码.当我重新添加它时,这些字符在MS Word中为我正确显示.

<cfprocessingdirective pageencoding="utf-8">
<cfheader name="Content-Disposition" value="inline; filename=Save-Print.doc" charset="utf-8">
<cfcontent type="application/msword; charset=utf-8">
<html xmlns:o="urn:schemas-microsoft-com:office:office"
      xmlns:w="urn:schemas-microsoft-com:office:word" 
      xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Print</title>
...

转载注明原文:ColdFusion,MS Word文档和希腊字符 - 代码日志