How to print Extended ASCII characters 127 to 160 in through a C program?

做~自己de王妃 提交于 2019-12-01 00:20:16

ASCII is a 7-bit code. The interpretation of byte values above 128 is dependent upon the OS, your locale/language settings, and so on. They are not standard. Under Windows in English, they are most commonly defined by CP1252; on Linux they are more commonly ISO-8859-1. Some OSs use UTF-8, which is not a character set itself but a way to encode Unicode into an 8-bit stream by using more than one byte for most characters. If you really need to work with characters outside the standard ASCII 32-126, you should really be using wide characters and locale stuff.

BTW, character 127 is a special case: it's the control character "rubout", which denotes erased data. (This was done so that a section of paper tape could be erased by punching all the holes!--yes, some of us are old enough to remember paper tape).

You might want to look into setlocale. I don't know which set of characters you're looking for but you could try setlocale (LC_ALL,""); to set your printed characters to match the environment (which seems to match your requirement since copy-pasting worked).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!