Replacing English keyword with Chinese in RTF

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Replacing English keyword with Chinese in RTF

    Hi there,
    I'm replacing a keyword "replacename" in a Chinese language rich text format
    document with a value from a form. It works okay when I type English into the
    form, but Chinese characters aren't decoded correctly in the RTF.
    I'm adding utf-8 as the charset to everything possible in the page. The email
    notification displays the Chinese name correctly in the title and body. The
    attachment RTF is displaying funny Euro characters instead of funny Sino
    characters for the name.
    Any help is much appreciated.
    Thanks,
    Sierra

    <!--- Final --->
    <cfset charset = "utf-8">
    <cfprocessingdirective pageEncoding="utf-8">
    <cfcontent type="text/html; charset=utf-8">
    <cfscript>
    SetEncoding("FORM", charset);
    </cfscript>
    <cfset this_path = GetDirectoryFromPath(GetCurrentTemplatePath())>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>
    <head>
    <cfoutput><meta http-equiv="Content-Type" content="text/html;
    charset=#charset#"></cfoutput>
    <title>Print Survey</title>
    </script>
    </head>

    <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0"
    marginwidth="0" marginheight="0">
    <cfinclude template="top.cfm">
    <cfset tab="thankyoutab.gif" >
    <cfinclude template="tabcont.cfm">

    <cfif not isDefined("Form.NameLast")>
    <cfoutput><form action="http://#CGI.SERVER_NAME#/#CGI.SCRIPT_NAME#"
    method="post"></cfoutput>
    First Name: <input type="text" name="NameFirst" value=""><br>
    Last Name: <input type="text" name="NameLast" value=""><br>
    Type of Chinese:
    <input type="radio" name="ChineseType" value="Simple" checked> Simple
    <input type="radio" name="ChineseType" value="Traditional"> Traditional<br>
    <input type="submit">
    </form>
    <cfelse>

    <cfset docpath = Replace(this_path, "survey",
    "docs\chinese_#Form.ChineseType#\wintro2", "ALL")>
    <cfset testID = RandRange(0,500)>
    <cfoutput>Encoding: #GetEncoding("FORM")#<br><br></cfoutput>

    <cfloop from="1" to="1" index="i">
    <cfloop from="3" to="9" index="j">

    <!--- Read Description w Intro template. Insert text and save as temp file
    for attaching --->
    <cfset filepath1 = "#docpath#Profile&intro#i#_#j#.rtf">
    <cfset temppath1 = "#docpath#out\Print_Description_#testID#_#i#-#j#.rtf">
    <CFFILE ACTION="Read" FILE="#filepath1#" VARIABLE="expage1"
    charset="#charset#">
    <cfset expage1 = ReplaceNoCase(expage1, "replacename", Form.NameFirst & " "
    & Form.NameLast, "ALL")>
    <cfset expage1 = ReplaceNoCase(expage1, "1999-2001 SDI", "1999-#Year(Now())#
    SDI", "ALL")>
    <CFFILE ACTION="Write" FILE="#temppath1#" OUTPUT="#expage1#"
    charset="#charset#">

    <cfset attachpath = temppath1>

    <!--- Send Email w Attachment --->
    <CFMAIL TO="notify@brighterfusion.com"
    FROM="info@nowhere.com"
    SUBJECT="Results for #Form.NameFirst# #Form.NameLast#"
    TYPE="HTML"
    TIMEOUT="30"
    charset="#charset#"
    mimeattach = "#attachpath#">

    <p>Survey Results<br>
    for #Form.NameFirst# #Form.NameLast#<br>
    ================================================== ====================<br>
    Major: #i# &nbsp;&nbsp;
    Minor: #j# &nbsp;&nbsp;
    <br>
    ================================================== ====================<br>
    Your Print Description is attached to this document.

    <cfoutput>#Asc(Left(Form.NameFirst,1))# #Form.NameFirst# #Form.NameLast#
    #Asc(Right(Form.NameFirst,1))# #i# #j#<br></cfoutput>
    </cfloop>
    </cfloop>

    </cfif>

    <cfinclude template="footer.cfm">
    </body>
    </html>
    <!--- End Final --->

    sbufe Guest

  2. Similar Questions and Discussions

    1. Chinese karakters in English Freekhand?
      Is there any way an English version of Freehand can handle Chinese typeface? I've opened a rtf-word file with Chinese typeface in Freehand, but it...
    2. Keyword Parsing with ASP
      I am writing a search program in ASP(VBScript). The user can enter keywords and press submit. The user can separate the keywords by spaces and/or...
    3. old english
      does anyone know where i can download the old english font ?
    4. Does anyone know how to input chinese characters in freehand10 english
      ya, on mac, it can display chinese correctly when using Freehand 10 (english ver.) but when i tried to print as PDF by the PDF writer, some chinese...
    5. Keyword not supported
      Hi, I have an ASP app that queries MS Indexing Service. Below is my code. ############################# Imports System Imports...
  3. #2

    Default Re: Replacing English keyword with Chinese in RTF

    starting simple, have you wrapped the chinese text in a font that can display it?

    PaulH Guest

  4. #3

    Default Re: Replacing English keyword with Chinese in RTF

    Yes, I changed the font around the keyword to MingLiU in the RTF template.
    Thanks,
    Sierra
    sbufe Guest

  5. #4

    Default Re: Replacing English keyword with Chinese in RTF

    Nevermind that there's a missing /cfmail tag in that sample text.

    So, as I look into the RTF, I see that the unicode character is represented
    like this:

    \uc2\u24615\'a9\'ca

    Which is Unicode, 2 bytes, Unicode number 24615, and then the two hex bytes,
    right? When I use CF to replace the keyword with a known character, say U+
    20154, it doesn't put that number into the code, or the correct hex reference
    either.
    Do I have to put it into the RTF in this kind of format, rather than feeding
    in the character by itself? In other words, should I only do a replace using
    ASCII representation of the Unicode like above?
    -Sierra

    sbufe Guest

  6. #5

    Default Re: Replacing English keyword with Chinese in RTF

    And in another whole subject, but it's driving me crazy while I'm trying to fix
    this, my Dreamweaver keeps modifying my code every time I save, changing this:

    <!--- Final --->
    <cfprocessingdirective pageEncoding="utf-8">
    <cfcontent type="text/html; charset=utf-8">
    <cfset charset = "utf-8">

    to this:

    <!--- Final --->
    <cfprocessingdirective pageEncoding="#charset#">
    <cfcontent type="text/html; charset=#charset#">
    <cfset charset = "utf-8">

    I don't even know how that's possible, but it's VERY time consuming to change
    it back with every page save I make!
    Sierra

    sbufe Guest

  7. #6

    Default Re: Replacing English keyword with Chinese in RTF

    More confusion. When I convert 24615 to hex, the answer is not a9ca but 6027.
    Is there another way I should be converting this? I'm not sure where the two bytes come from, exactly.
    -Sierra
    sbufe Guest

  8. #7

    Default Re: Replacing English keyword with Chinese in RTF

    you might want to read thru
    [url]http://www.macromedia.com/cfusion/webforums/forum/messageview.cfm?catid=7&thread[/url]
    id=998012&enterthread=y. can you attach a simple example of your RTF file?

    sorry, i don't use DW. no idea why it would be re-writing your code but i 'd
    guess you told it to somehow.

    PaulH Guest

  9. #8

    Default Re: Replacing English keyword with Chinese in RTF

    Hi Paul,
    I appreciate your help. Yesterday the client enlisted the help of a Chinese
    programmer, and we found the solution, which was to convert any unicode char to

    \u#Asc(char)# ?

    which is pretty much what you said too. I was stuck on trying to figure out
    the \' stuff, but it seems that that's optional, because it's working without
    it.
    Thanks,
    Sierra

    sbufe Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139