[Mono-bugs] [Bug 600844] New: RichTextBox.Rtf returns Unicode chars (get_Rtf), but does not accept Unicode chars (set_Rtf)
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Thu Apr 29 06:07:45 EDT 2010
http://bugzilla.novell.com/show_bug.cgi?id=600844
http://bugzilla.novell.com/show_bug.cgi?id=600844#c0
Summary: RichTextBox.Rtf returns Unicode chars (get_Rtf), but
does not accept Unicode chars (set_Rtf)
Classification: Mono
Product: Mono: Class Libraries
Version: 2.6.x
Platform: x86-64
OS/Version: Windows 7
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Windows.Forms
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: jm at grassau.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64;
Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729;
Media Center PC 6.0; MDDC)
If a RichTextBox contains Unicode chars (e.g. German umlauts or Greek chars),
RichTextBox.Rtf will return a string that contains correct Unicode chars.
However, if the same string is stored back to RichTextBox.Rtf, the chars appear
as "???". (This may be a similar problem as in Bug 586901)
Reproducible: Always
Steps to Reproduce:
1. Create a Form and enter the following code:
Public Sub New()
InitializeComponent()
Dim RichTextBox1 As New RichTextBox
Dim RichTextBox2 As New RichTextBox
'now RichTextBox1.Text is set to German umlauts "äöü" and Greek alpha "α":
RichTextBox1.Text = ChrW(228) & ChrW(246) & ChrW(252) & ChrW(945)
RichTextBox2.Rtf = RichTextBox1.Rtf
MsgBox(RichTextBox1.Text & " -> " & RichTextBox2.Text)
End Sub
2. Run the program.
Actual Results:
If run in .NET, MsgBox shows "äöüα -> äöüα"
If run in MONO, MsgBox shows "äöüα -> ????", i.e. all the Unicode characters
were replaced by "?".
RichTextBox1.Rtf returns a correct string that contains Unicode chars. However,
when setting RichTextBox2.Rtf to this same string, only ASCII Chars 0-127 are
accepted by Mono, and anything else is replaced by "?".
Expected Results:
As in .NET, Mono should accept all Unicode chars when setting RichTextBox.Rtf,
so MsgBox should show "äöüα -> äöüα".
Things work in MONO, if you convert RichTextBox1.Rtf to plain ASCII chars 0-127
before setting the string to RichTextBox2.Rtf:
Public Sub New()
InitializeComponent()
Dim RichTextBox1 As New RichTextBox
Dim RichTextBox2 As New RichTextBox
RichTextBox1.Text = ChrW(228) & ChrW(246) & ChrW(252) & ChrW(945)
'note that RichTextBox1.Rtf is now converted before it is stored to
RichTextBox2.Rtf:
RichTextBox2.Rtf = ReplaceUnicodeChars(RichTextBox1.Rtf)
MsgBox(RichTextBox1.Text & " -> " & RichTextBox2.Text)
End Sub
Private Function ReplaceUnicodeChars(ByVal RichText1 As String) As String
Dim StringBuilder1 As New System.Text.StringBuilder
Dim Char1 As Char
For Each Char1 In RichText1
Select Case AscW(Char1)
Case Is < 128 'normal ASCII Char 0-127
StringBuilder1.Append(Char1)
Case Is < 256 'Char 128-255
StringBuilder1.Append("\'" & Hex(AscW(Char1)))
Case Else 'Unicode Char
StringBuilder1.Append("\u" & AscW(Char1).ToString & "?")
End Select
Next
Return StringBuilder1.ToString
End Function
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list