I have following basic HTML setup for org-mode

#+TITLE: Blog
#+AUTHOR: Burak Kaan Çopur


and this gives me following head in generated HTML file

<!DOCTYPE html>
<html lang="en">
<!-- 2018-02-22 Thu 22:11 -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="generator" content="Org mode">
<meta name="author" content="Burak Kaan Çopur">

You can see that charset is set to UTF-8 and language of the document is set to en. When I write HTML manually, I use these settings and my name which includes a Ç shows just fine. But org exported HTML files are not able to display them. What might be the problem here?

Here is what causing me the problem. I opened one of the .org files in Notepad++ and said convert to UTF-8. When I republish through emacs, this time it works but if I reopen the same file in emacs then it is messed up again. I have following in my configuration so I was thinking my emacs buffers are all encoded in UTF-8

;; UTF-8 as default encoding
(set-language-environment "UTF-8")

So what might be the reason for emacs to not use UTF-8 encoding?

  • Can't confirm this on Emacs-26.0.1 and org-mode 9.1.3. – Dieter.Wilhelm Feb 23 '18 at 8:04
  • Could a script or CSS file loaded later in the document mess with the encoding? – meguli Feb 23 '18 at 11:21
  • I opened the .org file in Notepad++ and said convert to UTF-8. Then when I published, it worked fine. So I am guessing, emacs is not saving the file in UTF-8 encoding. I will update the question. – meguli Feb 23 '18 at 11:41
  • Anyone want to explain the downvote? – Dan Feb 23 '18 at 13:57
  • @Dan For using Notepad++ to change the encoding instead of using Emacs! ;-) In earnest the problem is not related to org-mode! It's a mishandling of Emacs, the user doesn't know how to handle the file coding system, or how the "wrong" coding system appeared at all. – Dieter.Wilhelm Feb 24 '18 at 18:14

Here is how I solved the problem. I had this on my .emacs file.

;; UTF-8 as default encoding
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)

I thought these makes every buffer encoded in utf-8. In reality, if one of your files have a different encoding for some reason, emacs will use that encoding. But If you open a new file, emacs will use utf-8 by default. So my .org files were encoded differently, I don't know how that happened. To change them, I used

C-x RET c

This prompts you to chose an encoding, I went for utf-8. Then asks for a command to execute with this encoding. I said C-x C-s to save using utf-8. That solved my problem.

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.