Why does "my.computer.readalltext" fail when reading an apostrophe? Is it an Ascii vs Unicode problem

gideon isaac 81 Reputation points

I have a program that reads in a text file (the text file was pasted from a web page into a text editor called 'editpad'.) The text file has a line like this:
The Afghanistan Withdrawal’s Smoking Gun Emerges
I read in the file with the VB.net statement: "mycontents = My.Computer.FileSystem.ReadAllText(strFileName)"
But when I look at myContents with the debugger, the apostrophe has become a questionmark surrounded by a black diamond, somewhat like this:
The Afghanistan Withdrawal?s Smoking Gun
So why doesn't the apostrophe remain as a legible apostrophe character? Does it have something to do with unicode being read by a line that expects ASCII?

An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,566 questions
0 comments No comments
{count} votes

1 additional answer

Sort by: Most helpful
  1. WayneAKing 4,921 Reputation points

    The Afghanistan Withdrawal’s Smoking Gun Emerges

    If the text that you posted is what you are actually using,
    from copy/paste, then the character you are referring to as
    an apostrophe is not really the apostrophe character which
    is 0x27.

    It is the Right (or Closing) Single Quotation Mark which
    is 0x92.

    Depending on the font used to display this character it may
    look like the apostrophe, but more often looks like an
    elevated comma or a right-leaning vertical dash such as
    an acute accent mark, etc. If the font does not have a
    displayable character for 0x92 it may show a substitute
    used when it encounters a non-displayable character.
    That is often a question mark.

    People sometimes mistakenly enter this character instead
    of an actual apostrophe when typing from a keyboard that
    has a key for that character. Or they deliberately use it
    simply because it may resemble an apostrophe - to a human.

    • Wayne
    0 comments No comments