2

I want my default encoding stay utf-8.
But when under Windows - I want to see some of my file names in dired using cp1251. (Because of no utf support in Windows)

Everything displays like: \361\345\354

So how can I make this:

(setq coding-system-for-read 'cp1251)

only for dired mode but not others?

sashoalm
  • 75,001
  • 122
  • 434
  • 781
Sergey
  • 19,487
  • 13
  • 44
  • 68

1 Answers1

5

You can try this:

(add-hook 'dired-mode-hook
          (lambda ()
            (make-local-variable 'coding-system-for-read)
            (setq coding-system-for-read 'cp1251)))
Saddle Point
  • 3,074
  • 4
  • 23
  • 33
  • I almost did it, I haven't used make-local-variable, just don't have enough knowledge of emacs, thanks – Sergey Dec 28 '12 at 14:28
  • @Sergey My pleasure, you can read something about it: http://technical-dresese.blogspot.com/2012/12/hooks-local-variables-and-namespaces.html – Saddle Point Dec 28 '12 at 14:32
  • Great! I was suffering from undecoded utf-8 for ages. Thanks to SO and you it is fixed now! :) – Seki Aug 19 '19 at 10:45