Format Unicode string for InDesign. A Coldfusion UDF.
Sunday 29 August 2010 01:07 PM
I was generating InDesign JSX files with Coldfusion, to create pdfs that happened to have Unicode characters in it. That is not a difficult task, but rather boring one, until I realize, I cannot use Unicode characters inside InDesign JavaScript file. JSX only accept Unicode characters by their "glyph id number" or "code point" or whatever the name you geeks prefer to call it. So here I put together a small ColdFusion function to format all Unicode characters in a string, to inDesign friendly code points. I prefer to save ascii characters as it is, so if I had to read the converted string, it would make some sense to me.
This function will convert a sting like "Peace™ Justice® and යුනිකෝඩ්"
In to InDesign script friendly string like
"Peace\u2122 Justice\u00AE and \u0DBA\u0DD4\u0DB1\u0DD2\u0D9A\u0DDD\u0DA9\u0DCA"
1: <cffunction 2: name = "toCodePoint" 3: returntype ="string" 4: output = "no" 5: description = "Convert Unicode in to inDesign friendly code point values"> 6: <cfargument name="string" required="Yes" type="string"> 7: 8: <cfset newString = ""> 9: <cfloop from="1" to="#len(arguments.string)#" index="i"> 10: <cfset thisChr = mid(string,i,1)> 11: <cfset deci = asc(thisChr)> 12: <cfif deci gt 4096> 13: <cfset newString = "#newString#\u#Ucase(FormatBaseN(deci,16))#"> 14: <cfelseif deci gt 255> 15: <cfset newString = "#newString#\u0#Ucase(FormatBaseN(deci,16))#"> 16: <cfelseif deci gt 127> 17: <cfset newString = "#newString#\u00#Ucase(FormatBaseN(deci,16))#"> 18: <cfelse> 19: <cfset newString = "#newString##thisChr#"> 20: </cfif> 21: </cfloop> 22: 23: <cfreturn newString> 24: </cffunction>
Posted by Saman W Jayasekara at Thursday 24 December 2009 11:57 PM .
inDesign Server
.
ColdFusion

j.v.subramanyam
on Friday 16 December 2011 02:04 AM
when i am creating pdf using cfdocument some of the unicode fonts like hindi are not visible in the pdf. other fonts like telugu, tamil are visible in pdf. when I cahnged the fromat of cfdocumen from pdf to Flashpaper the hindi fonts also visible. when i combined the hindi and telugu fonts the hindi fonts are showing properly , but the telugu fonts are showing as junk. Please help me.
on Wednesday 21 December 2011 01:33 PM
Are you using InDesign server to make PDF of coldfusion cfpdf tag? this sound more like a font issue. if it's a indesign server, make sure fonts are also copied in to InDesign server's font folder. if it's CFPDF, try using another font and also make sure fonts are registred with the cf admin.

Sam
on Thursday 07 April 2011 04:17 PM
CS5 should work with Unicode characters without special formatting.

Joel Stobart
on Thursday 07 April 2011 05:40 AM
Seems to not work in cs5 - puts the replacement characters into the strings
e.g. \u205c appears as "\u205c"...