How To: Find Special Characters in a SQL Script

Currently Datical supports the encodings listed in the Supported Encodings section of this page. This article includes instructions to help identify special characters in a sql script.

Supported Encodings

Datical supports the following encodings:

ISO-8859-1 US-ASCII UTF-16 UTF-16BE UTF-16LE UTF-8

Instructions for Finding Special Characters

If you receive an error such as "Unrecognized character" or "Invalid character" the sql script likely contains non-UTF characters which need to be removed from the sql script.

  1. Open the file in Notepad++.

  2. In the lower right of the screen you can find the file encoding.

    1.  

  3. To find non UTF-8 in Notepad++ go to Encoding → Encode in UTF-8. The setting should highlight the special characters.

    1.  

  4. In the screenshot above the xA0 represents non UTF-8 characters that will throw errors when the script is passed to sqlcmd, sqlplus, and other utilities. Those characters will need to be deleted from the feed.

  5. Additional if you want Notepad++ to move the cursor to non UTF-8 characters for easier removal, go to Search → Find characters in range…

    1.  

    2. Select Non-ASCII Characters (128-255)

       

    3. Use ‘Find’ button to move the cursor to the special characters.

Commands for removing special characters

  1. There are also a variety of programmatic methods for removing special characters. For example, you can use git bash to remove special characters with the tr command (from https://alvinalexander.com/blog/post/linux-unix/how-remove-non-printable-ascii-characters-file-unix/).

Please note, you may need to manipulate the command below if you wish to keep certain special characters as this will strip out ALL special characters. It would need to be used with caution:

tr -cd '\11\12\15\40-\176' < file-with-binary-chars > clean-file

 

Copyright © Datical 2012-2020 - Proprietary and Confidential