Works for me. What platform and how are you running the script?
Most importantly: what does it insert instead? Post a screenshot of the "other special characters," please.
I think I figured it out, and I needed to use something like:
myTextFrame.insertionPoints[-1].contents = String.fromCharCode(0x00E9);
to make the special "e" character.
It seems like some of the symbols work but not others. The "other special characters" that it rendered before was this "Â©".
I'm using Windows 7 with CS5, but I was running the script on our development InDesign Server.
You should answer the questions I asked, like how you're running the script.
I suspect whatever editor you are using to save the script is not writing it in UTF-8 format.
You can certainly use that syntax, though more convenient is the \u syntax: "The caf\u00e9".
But it should not be necessary.
You should read my answers, like "running the script on our development InDesign Server". If you need more details, just ask.
The script is written in a process and saved on a server before getting executed on our InDesign Server, but I'm testing with Adobe's Extend Script Tool Kit, but I'm not sure if it uses the UTF-8 format or not.
Thanks for the help.
Indeed I did read your post, but "running the script" is not an answer to "how are you running the script."
Are you using the ESTK? Are you using the CORBA interface? Are you using the SOAP interface? Are you using one of the script-running API utillities that come with InDesign server? Are you doing something else?
How are you running the script?
The ESTK does indeed use UTF-8. Does it work properly in InDesign Desktop? Your example from the ESTK under Windows XP to InDesign Desktop works fine for me.
As John suggested, it is almost certainly a character encoding issue at script-editing level. I have similar troubles when I deployed my first scripts for Mac + Win platforms—there was always users who got degenerate UTF8. Since I'm not an expert in cross-OS character encoding, I decided to never use non-ASCII characters in my script. This is a radical solution, I admit, but my scripts never more displayed weird Â© strings and so.
myTextFrame.insertionPoints[-1].contents = "The caf\xE9...";