Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Using utf-8 for superscript 4 and showing in combobox

Using utf-8 for superscript 4 and showing in combobox

Scheduled Pinned Locked Moved Visual Basic
xmlquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fawxes
    wrote on last edited by
    #1

    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

    G 1 Reply Last reply
    0
    • F Fawxes

      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

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      The html code for superscript is <sup>. I don't know how well that works in a combobox, though. --- b { font-weight: normal; }

      F 1 Reply Last reply
      0
      • G Guffa

        The html code for superscript is <sup>. I don't know how well that works in a combobox, though. --- b { font-weight: normal; }

        F Offline
        F Offline
        Fawxes
        wrote on last edited by
        #3

        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

        F G 2 Replies Last reply
        0
        • F Fawxes

          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

          F Offline
          F Offline
          Fawxes
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • F Fawxes

            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

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            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 &lt;sup&gt;superscript&lt;/sup&gt; 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; }

            F 1 Reply Last reply
            0
            • G Guffa

              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 &lt;sup&gt;superscript&lt;/sup&gt; 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; }

              F Offline
              F Offline
              Fawxes
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups