Skip to main content
Participant
April 10, 2008
質問

Want to use CFSET to set a Chinese character

  • April 10, 2008
  • 返信数 1.
  • 514 ビュー
I have a page translated into Chinese. For example, the translation for the word "false" is 错 (Unicode?).
That works fine when displaying the page, but I need to use CFSET to set a variable (true/false quiz).

So, I want to do this:
<cfif a1 is "false"><cfset c1="&#38169;"><cfelse><cfset c1="&#23545;"></cfif>

But, I get a CFML error (it balks at the semicolon, it seems). Anybody know how I can set a variable to, in this case, a Chinese character?
Thanks
    このトピックへの返信は締め切られました。

    返信数 1

    Inspiring
    April 10, 2008
    Howard Perlman wrote:
    > I have a page translated into Chinese. For example, the translation for the
    > word "false" is &#38169; (Unicode?).

    yes that looks like something in the CJK range for unicode BUT you better make
    sure that's the encoding that the translator's actually supplying.

    > That works fine when displaying the page, but I need to use CFSET to set a
    > variable (true/false quiz).
    >
    > So, I want to do this:
    > <cfif a1 is "false"><cfset c1="&#38169;"><cfelse><cfset c1="&#23545;"></cfif>

    you don't have to use that NCR, you can copy paste the actual char if you have a
    unicode compliant editor (notepad even). otherwise escape the pound sign (#):

    <cfset c1="&##23545;">

    Participant
    April 10, 2008
    Thanks PaulH...
    Dang, I forgot about escaping the # sign - it works fine now.
    ( http://ga.water.usgs.gov/edu/languages/chinese/quizgw.html) (Not quite finished yet, but soon).

    The way I've been posting the translations is to take the MS Word file the translator send me, saving it out as filtered HTML, which converts the Chinese characters into the Unicode numeric codes. Then I cut and paste into Homesite for the Web page. I know little about this, but I assumed that by using numeric codes that a user would not need any Chinese fonts installed. Not sure about that.

    But, the translator reviews the pages and she sees correct Chinese. I wonder what someone in Germany or Mississippi sees, but I have to assume they see the Chinese, too.
    Thanks.