[英]RichTextbox, RTF in VB.NET
I am using richtextbox in vb.net , which contains the value "секция", which is russian word. 我正在vb.net中使用richtextbox,其中包含值“секция”,这是俄语单词。
rtf1.selectedrtf
and rtf.rtf
, it returns /Un
representation of characters. rtf1.selectedrtf
和rtf.rtf
,它返回字符的/Un
表示。 Is there any way or option in rtf
to return the value in \\uXXXX
format?. rtf
是否有任何方法或选项以\\uXXXX
格式返回值?
секция='f1\'e5\'ea\'f6\'e8\'ff
секция=\u0441\u0435\u043A\u0446\u0438\u044F (<-- i need this format)
=============================
rtf1.text=секция
rtf1.selectedrtf returns
"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset204{\*\fname Arial;}Arial CYR;}} \uc1\pard\b\protect\f0\fs16\'f1\'e5\'ea\'f6\'e8\'ff} "
I have a small function to convert a unicode string to unicode rtf text. 我有一个小功能,可以将unicode字符串转换为unicode rtf文本。
Private Function UnicodeStringToRtfText(str As String) As String
Dim arrStr As Char() = str.ToCharArray()
Dim retStr As String = ""
For Each ch As String In arrStr
If (AscW(ch) > 122) Then
retStr &= "\u" & AscW(ch) & "?"
Else
retStr &= ch
End If
Next
Return retStr
End Function
Hope this help! 希望有帮助!
You can use the Encoding class found in System.Text to get the format in utf 8. 您可以使用System.Text中的Encoding类来获取utf 8中的格式。
Eg: 例如:
Encoding.UTF8.GetBytes(RichTextBox1.Text)
For more details you can look at the following link at msdn: 有关更多详细信息,请查看msdn上的以下链接:
Encoding.UTF8 Property It has good coding examples that you can follow. Encoding.UTF8属性它提供了不错的编码示例,您可以遵循。 I did not find anyway to set the encoding for a richtextbox but you can using the encoding class to get the format that you desire. 无论如何,我都没有找到为RichTextBox设置编码的方法,但是您可以使用encoding类来获取所需的格式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.