Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
sbufe #1
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#
Minor: #j#
<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
-
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... -
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... -
old english
does anyone know where i can download the old english font ? -
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... -
Keyword not supported
Hi, I have an ASP app that queries MS Indexing Service. Below is my code. ############################# Imports System Imports... -
PaulH #2
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
-
sbufe #3
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
-
sbufe #4
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
-
sbufe #5
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
-
sbufe #6
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
-
PaulH #7
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
-
sbufe #8
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



Reply With Quote

