stdout and key press

0

when in console, if I press a key, some interrupt controller sends code of that key to CPU, which looks into some table and than represent that keypress by printing some charracter to stdout. But, is keyboard sending an ASCII code of that key, or just some standardised code? Since there is so many languages and extra characters, OS must further translate its code into some character according to user selected scheme, I guess. I ask, becouse I am from Czech Republic, and we use some characters that do not exists in standart ASCII code. So I was thinking, if I enter this character into a console, and then print it, lets say in C++ using cin and cout, and I have set locale to Czech, stdin must actually send some non-ASCII code of the character I pressed to input stream. Am I right?

Jack

Posted 2010-03-09T10:24:05.620

Reputation:

What platform? Windows, Linux or Mac OS X? – Peter Mortensen – 2010-03-09T12:48:52.433

Answers

2

For the first question: keyboards send scancodes, not ASCII or Unicode.

Software on the computer then interprets the scancodes, e.g. the BIOS during boot or the operating system. E.g. in Linux scancodes and shifting state are interpreted by kernel key maps that translate keycodes to 16 bit numbers, which are normally Unicode/ASCII characters.

Peter Mortensen

Posted 2010-03-09T10:24:05.620

Reputation: 10 992