I have some workflow scripts that make OPMLs of various selections so that I can import things into other programs. Frequently the OPML fails because of “gremlins” (invisible characters) in the Name field. (Many items are webarchives, etc., so the gremlin originates somewhere back in the process where the clipping first got into DTPO. I know no way to determine that DTPO document names contain these characters until we export the name in a script or elsewise - “show invisible characters” doesn’t apply to doc names.)
To fix this, I open the exported file in BBEDIT, use the zap gremlins feature there, and then all is well.
Looking for suggestions on whether I can fix the problem without the BBEDIT step, i.e., in the script.
I build the OPML from DTPO document fields (Name, Comment, etc.), putting each field “as string”, and the whole constructed file “as Unicode text”.
Most of my work these days is with Python and py-appscript, which is liberating after the frustration of Applescript.
You didn’t say what the actual gremlins were, but assuming they are characters below 0x20 and perhaps ESC, I might pass a string out to a utility like Darwin “tr,” rather than going through character-by-character in Applescript. (This choice largely for speed and maybe readability)
What else do you want to know?
Best wishes,
Charles
(EDIT: Of course another solution would be to script BBEdit to open your OPML file, zap gremlins and save…)