Display special characters in Labels

kumaraswamy

Member
Joined
Jul 24, 2009
Messages
12
Programming Experience
1-3
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
 
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.
 
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:
VB.NET:
Me.Label1.Text = My.Computer.FileSystem.ReadAllText("path", [COLOR="Green"]System.Text.Encoding.Default[/COLOR])
You can replace that Encoding with any specific one also.
 
Back
Top