Daniel,

I found that chr(28) is not the actual code for left double quote
copied from Word.  It is the resulting code when we try to store the
actual code, chr(8220), to our Oracle DB.  To cover new and old data,
we do a replacement on both.  The full code we use is below.

Hope that helps,
Jon

<!--- JG 02/26/06: replace non-printable characters that might
invalidate XHTML --->
<cffunction name="CleanUnprintables" returntype="string"
output="false" access="public" >
  <cfargument name="Text" type="string" required="true" >
  <cfscript>
    var Local = StructNew();
    Local.Text = Arguments.Text;

    Local.Text = Replace(Local.Text, chr(11), " ", "all"); /* vertical tab */
    Local.Text = Replace(Local.Text, chr(19), "-", "all"); /* short
dash from MS Word after saved to DB */
    Local.Text = Replace(Local.Text, chr(20), "--", "all"); /* long
dash from MS Word after saved to DB */
    Local.Text = Replace(Local.Text, chr(24), "'", "all"); /* left
single quote from MS Word after saved to DB */
    Local.Text = Replace(Local.Text, chr(25), "'", "all"); /* right
single quote from MS Word after saved to DB */
    Local.Text = Replace(Local.Text, chr(28), '"', "all"); /* left
double quote from MS Word after saved to DB */
    Local.Text = Replace(Local.Text, chr(29), '"', "all"); /* right
double quote from MS Word after saved to DB */

    Local.Text = Replace(Local.Text, chr(8211), "-", "all"); /* short
dash from MS Word */
    Local.Text = Replace(Local.Text, chr(8212), "--", "all"); /* long
dash from MS Word */
    Local.Text = Replace(Local.Text, chr(8216), "'", "all"); /* left
single quote from MS Word */
    Local.Text = Replace(Local.Text, chr(8217), "'", "all"); /* right
single quote from MS Word */
    Local.Text = Replace(Local.Text, chr(8220), '"', "all"); /* left
double quote from MS Word */
    Local.Text = Replace(Local.Text, chr(8221), '"', "all"); /* right
double quote from MS Word */

    return Local.Text;
  </cfscript>
</cffunction>


On 5/31/06, Daniel Kessler <[EMAIL PROTECTED]> wrote:
> I am trying to clean up some text that is entered into a form.  The
> text usually comes from Word but also comes from other sources.  I
> usually get a box instead of the char in this situation.  I'm using
> an include that I pulled off of cflib and I'm trying to adjust it.
> The code is basically:
> function ConvertSpecialChars(textin) {
>         return ReplaceList(textin, "#chr(28)#,#chr(145)#,#chr(146)#,#chr(147)
> #,#chr(148)#", "',',',#chr(34)#,#chr(34)#");
> }
>
> I added the chr(28) which seems to be the left side of a smart quote
> from Word but this doesn't seem to be cleaning that out and replacing
> it with a single quote (though now I realize it should be a double-
> quote).  Here's a test that I did that shows the bad char and it's
> number using asc(the_letter).  Even though it goes through this
> cleaning, it still shows a the chr(28) char.  In addition, though it
> doesn't show the bad right quote, when I go into the form to edit it,
> the invisible right quote is there and I can tell by moving the
> insertion point over letter by letter where it pauses at that spot.
>
> Anyhoo, why doesn't it replace this char and is there a better way of
> doing this?
>
> thanks and good morning (or whichever time you're at).
>
>
> _____________________________
>
> Daniel Kessler
>
> College of Health and Human Performance
> University of Maryland
> Suite 2387 Valley Drive
> College Park, MD  20742-2611
> Phone: 301-405-2545
> http://hhp.umd.edu
>
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:241854
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to