1

When I type e.g. a Spanish character (with the keyboard), what encoding is used to send that character to the application (e.g. notepad or Word)?

E.g. Does the keyboard send it as a Unicode character and the application convert it to its desired encoding (e.g. ANSI).

Does the default encoding of the OS play a role?

Windows and Linux please.

Yamcha
  • 1,264
  • 18
  • 24
  • In (modern) Windows at least it'll be UTF-16 internally until the point it's read by the application, and then if the application uses on of the old -A APIs then it'll be converted to the active code page at that point. However hopefully no-one's using those APIs anymore, and if you're using e.g. .NET app it will stay as UTF-16. – Rup May 20 '15 at 19:59
  • @Rup Do you happen to know what encoding browsers use? If I type a Spanish character, what encoding is used when submitting a form? – Yamcha May 20 '15 at 20:23
  • 1
    It should default to the character set / encoding of the page. Hopefully that's Unicode / UTF-8. – Eryk Sun May 21 '15 at 03:03
  • BTW, keyboards don't send Unicode characters. The keyboard sends scan codes. On Windows, the keyboard driver converts these to device-independent virtual-key codes that an application receives in `WM_KEYDOWN` and `WM_KEYUP` messages. A thread's message loop calls `TranslateMessage` to convert these messages to `WM_CHAR` messages (either ANSI or Unicode depending on the window class), which are typically dispatched to the window procedure. See [Using Keyboard Input](https://msdn.microsoft.com/en-us/library/ms646268) for example code. – Eryk Sun May 21 '15 at 03:06

0 Answers0