I was just testing some email code today and encountered the strangest problem. Specifically I was initializing a Net.Mail.MailAddress with an address string I copied from some 'foreign' email application, code like this:
No matter what I got this:
The only explanation I can think of is that the string is differently encoded, but I thought the encoding used in code editor was Unicode (Utf-8), and that text pasted from differently encoded strings would either be converted or appear differently in editor? Any ideas about this?
VB.NET:
Dim m As New Net.Mail.MailAddress("a@b.c")
editing the address in code editor gave same result, but when I typed the exact same string in a new code line it executed fine. There are no observable strange characters in the string. It was also not a glitch, I reproduced it several times, also including restarting IDE.System.FormatException was unhandled
Message="The specified string is not in the form required for an e-mail address."
Source="System"
StackTrace:
at System.Net.Mime.MailBnfHelper.ReadMailAddress(String data, Int32& offset, String& displayName)
...
The only explanation I can think of is that the string is differently encoded, but I thought the encoding used in code editor was Unicode (Utf-8), and that text pasted from differently encoded strings would either be converted or appear differently in editor? Any ideas about this?