Using utf-8 for superscript 4 and showing in combobox
-
I have an application that fills a combobox with the contents of an xml file. The xml file represents superscript 4 with
⁴
which shows as: ⁴ I can change the font of the combobox so that the superscript 4 is shown but it doesn't work on all fonts and to be honest the ones where it does work look hideous. I'm just looking for a way of displaying the superscript 4, does anyone have any ideas? :confused::confused::confused: An optimist's glass is half full. A pesimist's glass is half empty. An engineer goes and gets the right size glass. -- modified at 8:52 Friday 13th January, 2006 -
I have an application that fills a combobox with the contents of an xml file. The xml file represents superscript 4 with
⁴
which shows as: ⁴ I can change the font of the combobox so that the superscript 4 is shown but it doesn't work on all fonts and to be honest the ones where it does work look hideous. I'm just looking for a way of displaying the superscript 4, does anyone have any ideas? :confused::confused::confused: An optimist's glass is half full. A pesimist's glass is half empty. An engineer goes and gets the right size glass. -- modified at 8:52 Friday 13th January, 2006 -
The html code for superscript is <sup>. I don't know how well that works in a combobox, though. --- b { font-weight: normal; }
The problem I'm having is that I'm reading an xml file and have simple nodes with text so I can cast the node value to a string. If I use the <sup> tag I can't cast to a string and I would have to format the text in the combobox. It seems that utf-8 encoded characters is the simplest method if I can just get the font issue right. On the next message is a copy of the code I'm using to populate a collection of objects that is used as the datasource for the combobox. The display member of the combobox can be either the Name or Abbreviation nodes. An optimist's glass is half full. A pesimist's glass is half empty. An engineer goes and gets the right size glass. -- modified at 8:51 Friday 13th January, 2006
-
The problem I'm having is that I'm reading an xml file and have simple nodes with text so I can cast the node value to a string. If I use the <sup> tag I can't cast to a string and I would have to format the text in the combobox. It seems that utf-8 encoded characters is the simplest method if I can just get the font issue right. On the next message is a copy of the code I'm using to populate a collection of objects that is used as the datasource for the combobox. The display member of the combobox can be either the Name or Abbreviation nodes. An optimist's glass is half full. A pesimist's glass is half empty. An engineer goes and gets the right size glass. -- modified at 8:51 Friday 13th January, 2006
Put this in seperate message to reduce message size.
Public Sub PopulateFromXML(ByVal fileName As String) 'Collect the path for the dll Dim path As String path = System.Environment.GetFolderPath( _ Environment.SpecialFolder.CommonApplicationData) 'Read the xml file into a dataset Dim xmlFile As New System.Data.DataSet xmlFile.ReadXml(path & _ System.IO.Path.DirectorySeparatorChar & _ "Flowguard Limited " & _ System.IO.Path.DirectorySeparatorChar & _ "Engineering Dimensions" & _ System.IO.Path.DirectorySeparatorChar & _ fileName) 'Collect the unit type Dim unitType As String unitType = Convert.ToString(xmlFile.Tables("DimensionUnits").Rows(0).Item("Type")) 'Collect the units table Dim unitsTable As New System.Data.DataTable unitsTable = xmlFile.Tables("Unit") 'Loop through each row of the units table, adding a new unit each time Dim rowEnum As IEnumerator rowEnum = unitsTable.Rows.GetEnumerator While rowEnum.MoveNext 'Cast the enumerated object to a data row Dim currRow As DataRow currRow = CType(rowEnum.Current, System.Data.DataRow) 'Create a new unit object Try Dim newUnit As New Unit(Convert.ToString(currRow("Name")), _ Convert.ToString(currRow("Abbreviation")), _ Convert.ToDouble(currRow("Factor")), _ Convert.ToBoolean(currRow("IsMetric")), _ Convert.ToBoolean(currRow("IsSIUnit")), _ "Length") 'Add the unit to the collection Me.Add(newUnit) Catch formatEx As System.FormatException 'Provide a message string Dim origString As String = "There is a problem in the xml file " Dim msgString As String = "" 'Identify which value has the problem If Not (TypeOf (currRow("Name")) Is String) Then If msgString.Length = 0 Then
-
The problem I'm having is that I'm reading an xml file and have simple nodes with text so I can cast the node value to a string. If I use the <sup> tag I can't cast to a string and I would have to format the text in the combobox. It seems that utf-8 encoded characters is the simplest method if I can just get the font issue right. On the next message is a copy of the code I'm using to populate a collection of objects that is used as the datasource for the combobox. The display member of the combobox can be either the Name or Abbreviation nodes. An optimist's glass is half full. A pesimist's glass is half empty. An engineer goes and gets the right size glass. -- modified at 8:51 Friday 13th January, 2006
I don't see the problem with storing the tags in a string. Properly encoded in the xml file, it would look like this, as example:
<node>A value with <sup>superscript</sup> text.</node>
If you can't store the tags in the xml file, can't you replace the unicode character after you have gotten the data:str = str.Replace("\x1234", "<sup>4</sup>")
--- b { font-weight: normal; } -
I don't see the problem with storing the tags in a string. Properly encoded in the xml file, it would look like this, as example:
<node>A value with <sup>superscript</sup> text.</node>
If you can't store the tags in the xml file, can't you replace the unicode character after you have gotten the data:str = str.Replace("\x1234", "<sup>4</sup>")
--- b { font-weight: normal; }The problem is that the text doesn't show in the combobox. I presume (and I haven't tried it yet) that if I changed the text to "<sup>4</sup>" then this is what would show in the combobox and not the superscript character. The combobox isn't in a web browser its on a windows form. What I've doen is set the default font to lucida sans unicode and everything is fine, I'm almost sure it is a font issue. If i'm getting the wrong end of the stick poke me with the right end :confused: :confused::confused::confused: An optimist's glass is half full. A pesimist's glass is half empty. An engineer goes and gets the right size glass.