I am trying to output the ASCII character 131 (ƒ - Latin small letter f with hook) to a message box but for some strange reason, it appears as an empty string. I have the following VB.NET code:
Dim str As String = Convert.ToChar(131)
MessageBox.Show(str, "test", MessageBoxButtons.OK, MessageBoxIcon.Information)
Debug.Print(str)
In the above, the message box doesn't show anything but the debug.print statement shows the character properly in the "Immediate Window". I have about 70 other ascii characters that all work fine with this method but only a select few show up as blank (131 and the EN dash 150).
For example, the following works:
str = Convert.ToChar(164)
MessageBox.Show(str, "test", MessageBoxButtons.OK, MessageBoxIcon.Information)
Debug.Print(str)
I also tried converting to UTF8 but I get the same behavior as in the first code snippet:
Dim utf8Encoding As New System.Text.UTF8Encoding(True)
Dim encodedString() As Byte
str = Convert.ToChar(131)
encodedString = utf8Encoding.GetBytes(str)
Dim str2 As String = utf8Encoding.GetString(encodedString)
MessageBox.Show(str2, "test", MessageBoxButtons.OK, MessageBoxIcon.Information)
Debug.Print(str2)
Is this an encoding problem? Thank you for any insight.
EDIT: Just to clarify, I'm not actually trying to output the character to a message box. That code was just a test. I'm trying to pass the character as a string to a function that uses it in a 3rd party xml editor control, but it shows up as blank. Even while debugging in Visual Studio, you can see its value being equal to "".
EDIT 2: Thanks to some investigations from the accepted answer below, I discovered that I was using the wrong unicode character. For this f character, the code to use was ToChar(402). This worked perfectly. Thank you all.