A developer I work with had recently learned the lesson of what you see is not necessarily what you get. He had been troubleshooting some SQL to execute as part of automation script, and it kept failing. Everything looked correct, and it worked in SQL explorer but would give him a cryptic error when running as part of the script. After a few days of troubleshooting, he found out the issue was due to some of the characters in the script were in Unicode and not ASCII. After cleaning up the text in a text editor, the script worked!

How do we save ourselves from these types of errors? Unfortunately, most editors seamlessly render Unicode and as it were plain text so it is not something we can see or recognize, but you can help reduce the change by:

  • When copying your script from one editor to another, use paste as plain text. By doing this will remove any Unicode from the text you are trying to paste and gain a little peace of mind.
  • Past your text to Notepad, then copy/cut it from there as your new source. (This option is only if your editor of choice does not support a paste as plain text option)

Remember, our editors are built to help us and give us visual feedback about the text we write. So when you copy that text, paste it as plain text, so you do not bring over any extra information from your source application.

Categories: Code Tip