Below is a Python script for Macs which converts text into a format suitable for pasting into messages here.
For a cross-platform Java version, see this thread: HtmlEsc.java
Why would you need this? Because:
- it encodes all the accented characters in your source text, so they show up properly when posted.
- it encodes characters in non-Roman character sets like Cyrillic and Arabic. If you can create or copy the text, the script can encode it.
- it encodes the non-ASCII characters that word processors sprinkle into your text but which Mudcat and other sites don't properly recognize except in escaped form.
- it operates directly on the text on your clipboard/pasteboard, so you can massage the text with only one extra step, right before you paste to the web site.
For the complete scoop on why you need a tool like this, see the guide "Entering special characters."
The bad news:
- It only works on Mac (due to proprietary clipboard interfaces, and the absence of Python on most Windows boxes), probably only with OS 10.4 or later. It requires the PyObjC bridge, which I believe is standard issue on Macs, but which might only be available if you've installed Developer Tools.
- There may be cases in which the script won't be able to access the clipboard text, because it wasn't made available in the standard format the script relies upon.
- The script wipes out all word processor formatting and treats HTML directives as literal text to be escaped.
- If you aren't used to entering UNIX commands in a Terminal window, you'll need to recruit a techie type (like your 10-year-old) to get things set up. I've kept my installation instructions terse because a techie will know instantly what I mean.
Here's the one-time setup:
- Start a Terminal window.
- Determine a local folder in your search path in which to create the script. Change to that folder.
- Copy and paste the script to a plain text file (NOT a word processor file) and name it "htmlesc.py". Actually, you can give it any name you want, as long as it ends in a .py extension. If your editor tacks on a .txt extension, rename the file after saving it.
- Give yourself execute privieges:
chmod u+x htmlesc.py
And now you're ready to use it:
- Select the text that you want to encode and copy it to the clipboard.
- In a Terminal window, type:
Note: If you set things up right, it doesn't matter what directory you're in.
- Paste your text where you want it.
The first time you run the script, the Python interpreter will create a p-code file with the same name as your script file, but with a .pyc extension. Keep it around; if you delete it, the interpreter will just have to recreate it the next time you run the script.
I may add an option to preserve HTML tags, but you'd have to make sure any other angle brackets in your text were escaped.
My script follows in the next message.