[RESOLVED] Displaying Greek beta symbol in TreeView icon text (read from disk)
I was able to paste a Greek beta symbol from the MS Windows Character Map (Microsoft Sans Serif) directly into code, and can compile, and run and the symbol shows when the text string is used for a Treeview icon's text. However, when I loop through the Treeview structure, and save all the icon text strings to an ascii text file, then load the text file and fill in the strings for each Treeview icon, there is a strange symbol showing for the Greek beta.
What is the best practice for showing a Greek symbol in a Treeview icon's text string, saving this string to disk (ascii text), reading the file, and showing the Greek symbol in the respective Treeview icon's text? I do this all the time with HTML, but I think it's a UTF-16 issue(?).
Is there a switch setting for a Treeview that needs to be set to recognize UTF-16 text string characters?
Re: Displaying Greek beta symbol in TreeView icon text (read from disk)
the Greek symbol are not ASCII character so when you save them, they are replaced by the ASCII character of the same code (if i remember correctly)
try this page : https://stackoverflow.com/questions/...eek-characters
an alternative is to write all your character in unicode and call them like that
ChrW(&H3B1) (for alpha)
https://www.rapidtables.com/code/tex...haracters.html
Re: Displaying Greek beta symbol in TreeView icon text (read from disk)
Quote:
Originally Posted by
pel11
save all the icon text strings to an ascii text file
That's the problem. It's nothing to do with the TreeView. If the characters are displaying correctly to begin with then there's obviously nothing wrong with the control. The issue is how you're saving the text. You haven't shown us that so we can't tell you what you're doing wrong. The only thing you can save as ASCII text is ASCII text. If you have Unicode text, save it as that.
Re: Displaying Greek beta symbol in TreeView icon text (read from disk)
The fix was to encode what was being saved, using, e.g.
Code:
Dim sw As StreamWriter = New StreamWriter(FileName, True, Encoding.Unicode)
When reading in, you don't need to specify encoding in the streamreader, just use what you normally use:
Code:
Dim sr As New StreamReader(New FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Works very good, the same Greek character as that one used in the code (pasted from the character map) was saved to disk, and the font size and family were preserved.