Mercurial > mplayer.hg
comparison osdep/getch2-win.c @ 22442:56a0b0f8a66e
Add code to detect and convert to console codepage on Windows.
Patch by Zuxy Meng [zuxy.meng at gmail com]
author | reimar |
---|---|
date | Sun, 04 Mar 2007 19:04:08 +0000 |
parents | 6f183c95aafc |
children | 71b3e04d0555 |
comparison
equal
deleted
inserted
replaced
22441:6f183c95aafc | 22442:56a0b0f8a66e |
---|---|
2 | 2 |
3 // See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/VirtualKeyCodes.asp | 3 // See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/VirtualKeyCodes.asp |
4 // for additional virtual keycodes | 4 // for additional virtual keycodes |
5 | 5 |
6 | 6 |
7 #include "config.h" | |
7 #include <stdio.h> | 8 #include <stdio.h> |
8 #include <windows.h> | 9 #include <windows.h> |
9 #include "keycodes.h" | 10 #include "keycodes.h" |
10 #include "input/input.h" | 11 #include "input/input.h" |
11 // HACK, stdin is used as something else below | 12 // HACK, stdin is used as something else below |
132 void getch2_disable(){ | 133 void getch2_disable(){ |
133 if(!getch2_status) return; // already disabled / never enabled | 134 if(!getch2_status) return; // already disabled / never enabled |
134 getch2_status=0; | 135 getch2_status=0; |
135 } | 136 } |
136 | 137 |
138 #ifdef USE_ICONV | |
139 static const struct { | |
140 unsigned cp; | |
141 char* alias; | |
142 } cp_alias[] = { | |
143 { 20127, "ASCII" }, | |
144 { 20866, "KOI8-R" }, | |
145 { 21866, "KOI8-RU" }, | |
146 { 28591, "ISO-8859-1" }, | |
147 { 28592, "ISO-8859-2" }, | |
148 { 28593, "ISO-8859-3" }, | |
149 { 28594, "ISO-8859-4" }, | |
150 { 28595, "ISO-8859-5" }, | |
151 { 28596, "ISO-8859-6" }, | |
152 { 28597, "ISO-8859-7" }, | |
153 { 28598, "ISO-8859-8" }, | |
154 { 28599, "ISO-8859-9" }, | |
155 { 28605, "ISO-8859-15" }, | |
156 { 65001, "UTF-8" }, | |
157 { 0, NULL } | |
158 }; | |
159 | |
160 char* get_term_charset() | |
161 { | |
162 static char codepage[10]; | |
163 unsigned i, cpno = GetConsoleOutputCP(); | |
164 if (!cpno) | |
165 cpno = GetACP(); | |
166 if (!cpno) | |
167 return NULL; | |
168 | |
169 for (i = 0; cp_alias[i].cp; i++) | |
170 if (cpno == cp_alias[i].cp) | |
171 return cp_alias[i].alias; | |
172 | |
173 snprintf(codepage, sizeof(codepage), "CP%u", cpno); | |
174 return codepage; | |
175 } | |
176 #endif |