]> code.delx.au - gnu-emacs/blobdiff - lisp/term/w32console.el
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
[gnu-emacs] / lisp / term / w32console.el
index d52a4e6893202c885421b6110c47e9d7893936d1..bf1550f7c332a016773119b5eea6d159dd5895c6 100644 (file)
@@ -1,6 +1,6 @@
 ;;; w32console.el -- Setup w32 console keys and colors.
 
-;; Copyright (C) 2007-201 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2016 Free Software Foundation, Inc.
 
 ;; Author: FSF
 ;; Keywords: terminals
 
 (declare-function x-setup-function-keys "term/common-win" (frame))
 (declare-function get-screen-color "w32console.c" ())
+(declare-function w32-get-console-codepage "w32proc.c" ())
+(declare-function w32-get-console-output-codepage "w32proc.c" ())
 
 (defun terminal-init-w32console ()
   "Terminal initialization function for w32 console."
   ;; Share function key initialization with w32 gui frames
   (x-setup-function-keys (selected-frame))
+  ;; Set terminal and keyboard encodings to the current OEM codepage.
+  (let ((oem-code-page-coding
+        (intern (format "cp%d" (w32-get-console-codepage))))
+       (oem-code-page-output-coding
+        (intern (format "cp%d" (w32-get-console-output-codepage))))
+       oem-cs-p oem-o-cs-p)
+       (setq oem-cs-p (coding-system-p oem-code-page-coding))
+       (setq oem-o-cs-p (coding-system-p oem-code-page-output-coding))
+       (when oem-cs-p
+         (set-keyboard-coding-system oem-code-page-coding)
+         (set-terminal-coding-system
+          (if oem-o-cs-p oem-code-page-output-coding oem-code-page-coding))
+          ;; Since we changed the terminal encoding, we need to repeat
+          ;; the test for Unicode quotes being displayable.
+          (startup--setup-quote-display)))
   (let* ((colors w32-tty-standard-colors)
          (color (car colors)))
     (tty-color-clear)
@@ -76,4 +93,6 @@
   (tty-set-up-initial-frame-faces)
   (run-hooks 'terminal-init-w32-hook))
 
+(provide 'term/w32console)
+
 ;;; w32console.el ends here