Emacs c-mode can't recognize utf-8?

1

I need to read one C++ head file which has some Chinese and was encoded using utf-8.

Emacs should recognize this encoding, but it turns out:

enter image description here

Then, I changed it to text-mode, it works:

enter image description here

I also tested for python-mode, lisp-mode, etc, all works except c-mode, c++-mode, java-mode, seems there are something wrong with cc-mode, or the cc-vars?

Please help me if you know how to fix this weird problem.

Chris Zheng

Posted 2012-02-24T05:51:51.530

Reputation: 181

Answers

1

I posted this question to stackoverflow, and got an answer.

It's not because of the encoding, in c-mode, comments are using italic font, but the font I use is lack of italic Chinese font, so, can't recognize the utf-8 Chinese character.

Simple do this

(add-hook 'c-mode-common-hook
          (lambda () 
            (make-face-unitalic 'font-lock-comment-face)))

Problem solved.

Chris Zheng

Posted 2012-02-24T05:51:51.530

Reputation: 181