I’ve got a lot of duplicate Address Book entries with what I can best describe as non printing characters in the name. I’m trying to build a routine to strip them out. When I ask Applescript what they are it shows them as “” or ASCII 0. I’m not sure what I need to strip out.
I had this problem recently. The cause of my problem was the file encoding was utf-16. There’s no way I could find to change the file encoding. Instead I read the file into applescript, used text item delimiters to remove the offending character, then you can work with the text or write it back out to a new file.
To use text item delimiters I first needed the character I wanted to remove. So I just copied it from the results section in script editor. Then you can paste the copied character into this script and use it to remove the characters…
==assuming the varible badText has the text with the unwanted character==
set applescript’s text item delimiters to “” → put the copied character between the quotes!
set tidText to text items of badText
set applescript’s text item delimiters to “” → this time nothing goes between the quotes
set goodText to tidText as unicode text