My script is creating file and file names cannot use any illegal characters in filename. How to test does string contain any of those characters? Wikipedia: HFS Plus permits UTF-16 characters.
UTF-16 characters are generally acceptable - try this:
set N to «data utxt2661266326622660» as Unicode text set f to open for access ((path to desktop as text) & N & ".txt") close access f
The only barrier that comes to mind is that file/folder names must not contain a colon “:”.