Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone,


I have a problem in passing utf8 character into .rtf function of richtextbox object

example:
------------------
Dim utf8 as String = the quick brown Ǣ fox jump
richtextbox.rtf = utf8
-------------------

In above scenario, once you view the richtextbox, the Ǣ will be converted into one question mark.

anybody can suggest on how to perfectly render the utf8 characters upon passing it into the .rtf function of richtextbox?

I need to pass it in .rtf since i need to maintain the emphasis type of each word.

Thank you,
Chaegie
Posted
Comments
Sergey Alexandrovich Kryukov 21-Jun-11 4:31am    
For starters, string is represented in memory not as UTF-8 but as UTF-16. Did you know that?
--SA

1 solution

I found it: RTF is damn archaic!

It works with Unicode but internally convert it in legacy Windows format based on code pages (as of Windows 95 and earlier), 8 bits per characters, but the fragment of text is prefixed with the Windows code. I saw this encoding when I types Unicode characters (code points above FF) in WordPad. If also supports Unicode escapes like \u1234?. The question marks denoted fallback for the programs not supporting Unicode ("show ?"). Also RTF does not support code points beyond BOM in any way (by all new versions of Windows do support it via surrogate pairs; as far as I remember — since some service pack of Windows 2000).

You can simply try type what you need in WordPad, save the file and open it with the plain-text editor, to make sure your understand how it should be coded in all details. I just did it.

See http://en.wikipedia.org/wiki/Rich_Text_Format[^].

Why using such archaic legacy stuff? What's wrong with HTML? PDF, to the worst end?

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900