1

Because Firefox doesn't load local files with UTF8 characters like '📞, …, 🖥' in the HTML or the CSS correctly, since it does not receive a <meta charset="utf8" /> header, I need to tangle files with a Byte-Order-Mark.

I knew that my needed BOM was \xef\xbb\xbf or \357\273\277.

My first try was just prepending this block:

#+BEGIN_SRC fundamental
\357\273\277
#+END_SRC
That line in emacs is really 3 characters, not 12 as rendered here 

When I tangle with C-c -v -t, I get a "Select coding system" prompt twice, where I have to choose `utf-8-with-signature' both times.

That puts the BOM at the front of the file, but also another time at the end. Then I find-file-literally the tangle result file, to remove the trailing one manually. And I have a "superfluous" Source Block...

The other work-around, which I have been using since then: Using sed externally:

#+BEGIN_SRC shell :tangle no
sed -i  '1s/^\(\xef\xbb\xbf\)\?/\xef\xbb\xbf/' Empty.org.htm
#+END_SRC

and then I just tangle that chapter, and execute the shell block afterwards. That became muscle memory and thus fast (enough). But also another source block needed in the doc.

I always wondered about the correct™ way to do this. From my reading I suspect, there is a variable I can set somewhere as a header var, or in a property drawer.

1

I found the correct variable to set while on an unrelated research dig:

coding can be set in a Local Variables block like so:

 # Local Variables:
 # mode: org
 # coding: utf-8-with-signature
 # End:

Note: there is a leading space in each line of the preceding source block.

This setting then gets inherited by the tangled files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.