-
Jun 25th, 2022, 09:14 PM
#1
Thread Starter
Lively Member
[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?
Last edited by pel11; Jun 27th, 2022 at 05:05 PM.
-
Jun 26th, 2022, 02:52 AM
#2
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
Last edited by Delaney; Jun 26th, 2022 at 03:08 AM.
The best friend of any programmer is a search engine
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
-
Jun 26th, 2022, 10:47 PM
#3
Re: Displaying Greek beta symbol in TreeView icon text (read from disk)
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.
-
Jun 27th, 2022, 05:10 PM
#4
Thread Starter
Lively Member
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.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|