Strange Error “Invalid token  found on Line 1 at Column 55.”

I was building plugin for blog and found really strange error " Invalid token  found on line 1 at column 55.", Google it but found different solution but none of them work for me. Finally I realize that it is because of non printable hexcode inserted in my code which is causing whole issue.

Let me explain whole scenario,

I was building plugin where I like to get coldfusion code from user in texteditor and display output out it. I just created temprory .cfm file for it and include it into my output.cfm page so I can display actual executed content. To test it out I have copied code from ADOBE site and run it but I start getting "Invalid token" error. When I look into my code I didn’t find character  at all. After little bit googling I realize that it is because of hex code character inserted in my file. This happens mostly when we copied code from any editor, msword, Now to execute code I have to remove hex code which causing issue.

Best way to know hex code by using hexcode editor ( I used XVI32) and find out hex code (you will get column number and line from coldfusion error :)) which causing issue and replace your content through regular expression.

 

[code:cf]

<cfset local.matchcontent = ReReplaceNoCase(local.matchcontent,"[\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F\x10\x11\x12\x13\x14\x15\x1A\x1B\x1C\x1D\x1E\x1F\x16\x17\x18\x19\x7F\xA0]"," ","ALL")>

[/code]