A command (not from reading a file) in my AppleScript gets a string like this:
ERR-The book Gen cannot be found.
There are many signs that are not properly displayed here (in the editor preview):
When I set the clipboard to the string and convert it into unicode character values, it shows as this:
E\x00R\x00R\x00-\x00T\x00h\x00e\x00 \x00b\x00o\x00o\x00k\x00 \x00\x1c G\x00e\x00n\x00\x1d \x00c\x00a\x00n\x00n\x00o\x00t\x00 \x00b\x00e\x00 \x00f\x00o\x00u\x00n\x00d\x00.\x00
In other words, there are many \x00 signs in the string.
When I paste it to wwwDOTregextesterDOTcom I can search for it. Search for `\u0000’ will also find it.
However, when I use
if myStr contains "\\u0000" then --Edit: Someone pointed out to me that this is looking for string '\u0000' -- but not the unicode character, --but I don't know how to look for the unicode character \u0000
if myStr contains "\\x00" then
It does not work. It cannot detect either “\u0000” or “\x00”.
The result in Script Debugger:
(On the left, all results show only “E”. The string is cut off at the first “\x00”).
Some one pointed out to me that it is because utf-16 being parsed as utf-8. But I don’t know how to fix it.
Any help appreciated!