When I save a script in plain text with Script Editor, it’ll save it in MacRoman encoding.
OTOH, saving from Script Debugger will use UTF-8 encoding.
Both editors can open both encodings, but SE will update the file back to MacRoman right away.
Now, if I upload such an .applescript file in either format on my web server, which runs apache2, viewing the file in the browser will show it with the wrong encoding. Mainly the line continuation char (shift-return) will then appear either as Â (saved by SE) or as Â¬ (saved by SD). Both are bad if user then copies the text and pastes it into SE or SD.
See for yourself:
The only thing that works is by converting it manually (using BBEdit) into UTF-8 with BOM:
But I wonder if I can instead configure the web server in a way that viewing .applescript files will tell the browser to assume the files are in plain UTF-8 or MacRoman (one setting for all such files is okay)?
Those look identical to me. What am I missing?
Got it, now, thanks. I can see how that’s a problem.
I’m not sure this helps, but a minor correction: SE saves in Unicode (UTF-16) if there are Unicode characters in the code.
Why don’t you upload zip archiveed script?
Downloading the file is not the problem - if the user downloads it, it has the correct encoding. I can force a download with a setting in Apache. But I want to allow the user to view the source in the browser, and then be able to copy it with the correct encoding, if possible. The only way to accomplish that is to remember to add a BOM to the text, which I often forget.
Do you know my blog “AppleScript Hole”?
I post thousands of AppleScript samples on it.
All of lists have applescript:// URL link.
The link “Click Here to Open This Script” include “applescript://” URL link.
You can click it and receive some macOS security messages, contents will be transfered to Script Editor (or Script Debugger).
If you want to do same, you can do it with my “AS Publisher v19”.
This method is not download but event message between Web browser and Script Editor (or Script Debugger).
That’s a good work-around. It helps even the inexperienced Mac user to open the script in the right app and all (s)he has to it to hit Run. Thanks for the tip!
But I don’t understand what I need the AS Publisher for. Since I write my web sites in plain html, by hand, I can simply use an
applescript:// link instead of a
https:// link, right?
Read the code, that’s all.
This is a brilliantly-written script. (For anyone like me who does NOT read Japanese, you open a script in the Script Editor, then run the Publisher script in SD, and it gets published to HTML)
The results display perfectly in Chrome and Firefox, but Safari (on my US English system) displays this. Is there a way to fix this easily? Thank you for this script!
Further on this subject: I used to use this application to convert AppleScript to HTML, but it turns out to be a 32-bit executable, and unusable today:
I tried downloading the source code and compiling with
make -f, but get
*** missing separator. Stop. errors. I’ve tried to solve this with solutions from the web, but nothing that I’ve tried does anything to help. This is almost certainly a beginner error, and I hope someone might see an easy solution.
This script was written in Japanese environment.
I used Japanese width space character x2 as a fix indent character.
All of you can replace Japanese width space (string id 12288) into some character you like.
Text encoding settings on Safari may effect this character. You may have to select “UTF-8”.
Thank you! I am probably being ignorant, but I can’t find this in your code. Could you say where it is?
Also, should non-Japanese users replace the Japanese characters in this block with something else:
set comText to "<br><font size=" & quotChar & "2" & quotChar & ">【コメント】 " & comText & "</font><br>"
Thank you again for this excellent script.
Thank you! Meanwhile, I found that I could fix the problem by adding a tag, like this (adding one line, and inserting a reference to it in the
set htmlHeader line:
set charsetString to "<head>" & return & "<meta charset=" & quotChar & "utf-8" & quotChar & ">" & return & "</head>" & return
set htmlHeader to charsetString & "<table width=" & quotChar & "100%" & quotChar & " border=" & quotChar & "0" & quotChar & "cellspacing=" & quotChar & "2" & quotChar & " cellpadding=" & quotChar & "2" & quotChar & ">
EDIT: May I have your permission to post a modified version of your code with the Japanese text in the output and dialogs replaced by English text, and with the 2 Japanese width characters replaced by 8 nonbreaking spaces?
If you keep link to original post (Japanese version), you can post modified version to everywhere you want.
Thank you. (And I found that I did not need to add the
charset if I replaced the Japanese space character with 8
I also suggest that you add a description to the head of the script that explains both the purpose (which was not clear to me, i.e. it reads an applescript and pretty-prints it) and the usage.
When I tried, without understanding what to do with it, I had weird effects:
- When I ran it in SD first, I got just a dialog in Japanese and then it stopped. Looking at the code I figured out that it probably requires to run in SE instead.
- In SE, when run, it doesn’t even prompt me to choose an applescript file but immediately creates a html file.
- So it turns out that I’m supposed to use it like this: Save the script as an app, then open a script I wanted an html from in SE, then run the saved AS Publisher.
This should be explained in the comments at the top for making it an easy-to-use tool.
And thanks for making this tool!
BTW, to translate the Japanese text, PopClip with one of the many translation extensions (PopClip Extensions), especially Instant Translate — PopClip Extensions, makes this quite easy.