Results 1 to 3 of 3

Thread: Display special characters in Labels

  1. #1
    kumaraswamy is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Jul 2009
    Posts
    12
    Reputation
    60

    Cool Display special characters in Labels

    Hi,
    I have a label in my form which displays the text-content stored in a text file. However it is not able to display special characters like ", ', : etc. Instead it just puts a small rectangular box (same size as that of the text).

    How do I get them to display these characters? Should I not use text files in this case or do I have to turn on some control-properties? Can someone suggest?

    Thanks
    Kumar

  2. #2
    henryminute is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Jul 2009
    Location
    UK
    Posts
    57
    Reputation
    61
    The single quote and double quote are not special characters and a Label control should display them normally. (Try it by typing into the Text property in the Properties Window).

    This means that your problem might be the Encoding used by the text file. In case this is so, take a look at Determining what the file encoding is of a .txt or .sql file to see if it helps.
    Some create happiness wherever they go, others whenever - Oscar Wilde

  3. #3
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,451
    Reputation
    2727
    You haven't said how you read the text files, but it is likely you're using some reader with standard Utf-8 encoding, and that the text files have other encoding. I usually get the correct text using the Ansi default encoding rather than the standard Utf-8 like this:
    Code:
    Me.Label1.Text = My.Computer.FileSystem.ReadAllText("path", System.Text.Encoding.Default)
    You can replace that Encoding with any specific one also.

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
  •  
Harvest time tracking