Is there anyway, I can have my richtextbox display this character("•") with it showing the box like shape(when the richtextbox doesnt know how to read the character)?

Dani AI

Generated

The small square almost always means either an encoding mismatch (the byte in the source does not decode to the Unicode bullet U+2022) or the RichTextBox font doesn't contain that glyph. is reading text from a web stream and suggested character-level fixes — here are focused diagnostics and safe fixes to apply.

First, confirm what the program actually received (numeric Unicode value). In VB you can inspect the codepoint where the bad glyph appears:

' check numeric Unicode value at position i
Dim codepoint As Integer = AscW(text(i))
' expected &H2022 for the standard bullet character

If the value is something else (for example a single byte 0x95 from a Windows-1252 file), the StreamReader is decoding with the wrong encoding. When reading HTTP text, explicitly specify the correct encoding when creating the reader (many web-hosted "ANSI" files are Windows-1252):

Using resp = WebRequest.Create(url).GetResponse()
    Using sr = New IO.StreamReader(resp.GetResponseStream(), System.Text.Encoding.GetEncoding(1252))
        Dim text = sr.ReadToEnd()
    End Using
End Using

To replace a literal < with the Unicode bullet (without embedding the glyph in source text), use ChrW:

text = text.Replace("<", ChrW(&H2022))

Also verify the RichTextBox font includes U+2022 (try "Segoe UI Symbol" or "Arial Unicode MS"). Avoid Thread.Abort; if reading on a background thread marshal updates to the UI thread (Invoke/BeginInvoke or Task/async). If after correct decoding the glyph still appears as a box, the codepoint is wrong or the chosen font lacks the glyph — fall back to an ASCII alternative (e.g., *) or pick a Unicode-capable font.

Recommended Answers

All 11 Replies

Well first of all what character is that?

? It is one of those press a combo of button of keys

hmm try

char c = Convert.ToChar("•");
RTB.Text += c;

where shall I drop that code?

Im using this code to get text, that has the "•"

void readrss()
        {
            try
            {
                richTextBox1.Text = string.Empty;
                StreamReader x = new StreamReader(WebRequest.Create("").GetResponse().GetResponseStream());
                richTextBox1.Text += x.ReadLine();
                x.Close();
            }
            catch { }
            Thread.CurrentThread.Abort();

I could solve this for you but this is where programming comes into play.

This is where your logic comes into play.

Show me your thought process. give me your psuedo code.

How would I make it replace a character? All that does is add one, I need to replace a character?

hmm, Indexof(), Replace, and Substring() are your friend.

Would you be able to give me an example of replacing < with •

Well,

int Marker = yourstring.IndexOf('<');
char c = Convert.ToChar("•");
if (Marker != -1)
     yourstring = yourstring.Substring(0, Marker-1) + c + yourstring.SubString(Marker+1, yourstring.Length-Marker);

Not sure about the -1 or +1 test it out.

There is a error for SubString

EDIT: correction, its suppose to be Substring. fixed,.

EDIT 2: The < is still there, what should I do ?

Comon I gave you the clues.

Not sure about the -1 or +1 test it out.

Here

label1.Text = label1.Text.Substring(0, Marker ) + c + label1.Text.Substring(Marker+1, label1.Text.Length - Marker-1);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.