This is a migrated thread and some comments may be shown as answers.

UTF-8 in HTML-like formatted cells

2 Answers 238 Views
GridView
This is a migrated thread and some comments may be shown as answers.
RAG
Top achievements
Rank 1
RAG asked on 22 Jan 2013, 09:32 PM
Hi, :)

I use a radgridview inside my application where certain words inside of cells should be marked. At the moment I solved this via DisableHTMLRendering and manipulating the data displayed in the cells... for instance with 
cellInfo.Value = "<html>" + cellInfo.Value.ToString() + "</html>";
foreach (KeyValuePair<String, Color> kvp in this._highlightWords)
{
    cellInfo.Value = Regex.Replace(cellInfo.Value.ToString(), kvp.Key, "<span style=" + '"' + "background-color:" + System.Drawing.ColorTranslator.ToHtml(kvp.Value) + '"' + ">" + kvp.Key + "</span>", RegexOptions.IgnoreCase);
    string[] tmpString = Regex.Split(cellInfo.Value.ToString(), kvp.Key, RegexOptions.IgnoreCase);
}

I have a list of words to be marked and I want them to have a colored background... depending on the current word.

Works fine so far, but I do have problems with the encoding. Special characters, like "ä", "ö" are not displayed properly... is there any way to set the encoding?

I already tried to hard-convert my content to utf-8, but that didn't change anything.

byte[] utf8String = Encoding.UTF8.GetBytes(cellInfo.Value.ToString());
cellInfo.Value = Encoding.UTF8.GetString(utf8String);

The data is received from a SQLCE database... am I doing something wrong? Or is this only solvable via the webbrowsercolumns you mentioned in another thread? Will those webbrowsercolumns still be performant, if I do have thousands of them? :)

Thanks in advance!
Kind Regards
Fabian

2 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 23 Jan 2013, 09:01 AM
Hello Fabian,

Thank you for your question.

I would like to clarify that the Html-like and non Html-like text drawing uses a same method to draw strings - the GDI+ Graphics DrawString method which properly render such characters - so you should be able to display characters like "ä", "ö" in the both cases. Far as I know, the umlauts displayed directly in the font - so set the Grid Font property to the font "Arial Unicode MS" - if this does not help try to encode the value that comes from the database not the string from the cell Value - please, refer to this MSDN forum. 

I hope this helps.

Regards,
Peter
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
RAG
Top achievements
Rank 1
answered on 25 Jan 2013, 12:30 PM
Hello Peter,

I must apologize - the problem lies elsewhere and has nothing to do with the radGridViewControl. I'm very sorry, that I wasted your time!

Regards!
Fabian
Tags
GridView
Asked by
RAG
Top achievements
Rank 1
Answers by
Peter
Telerik team
RAG
Top achievements
Rank 1
Share this question
or