Peter Thiel’s CS183 Notes has a filename with the ASCII string: “Peter Thiel’s CS183.pdf” or at least that is how it prints out in Windows Explorer. However, while debugging my program, I noticed that the ' character isn’t the plain apostrophe, it has a (unsigned char) value of 146, not the expected 39.
To test to see if it was a bug in my program, I renamed the file and erased the character and retyped apostrophe. Sure enough, this time my program displayed the correct value. I reasoned therefore that it must be a Unicode character (since I don’t see it in the ASCII table). However, it isn’t a multibyte character because the next byte in the string is an ‘s’.
Can someone help explain whats going on here?
Your mistake is believing this string is ASCII.
If you are using a Windows machine with character encoding CP-1252 (see http://en.wikipedia.org/wiki/Windows-1252), then your “code” 146 is a
kind of quote (see the table at the wikipedia page).