+ Reply to Thread
Results 1 to 2 of 2

Thread: Unicode encoding in code editor?

  1. #1
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Age
    37
    Posts
    10,843
    Reputation
    1443

    Default Unicode encoding in code editor?

    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:
    Code:
    Dim m As New Net.Mail.MailAddress("a@b.c")
    No matter what I got this:
    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(Stri ng data, Int32& offset, String& displayName)
    ...
    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.

    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?

  2. #2
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Age
    37
    Posts
    10,843
    Reputation
    1443

    Default

    I finally got around to analyzing the ascii bytes of that string and it contained character 30 at start of string, this is a non-printable character called "Record Separator", it was used as data separator in serial storage in the sixties, and is not a valid char in email address. A weird thing to find in a textbox in a modern application, but a simple explanation to the problem.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts