Announcement

Collapse
No announcement yet.

How to replace a " ° " character in a vb script ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to replace a " ° " character in a vb script ?

    I am trying to build a specific weather forecast phrase to be sopken out of Sonos from different "Environment Canada" weather plugin devices.

    The problem I am having is I have a specific device string that contains the " ° " caracter that i would like to replace by "Degré Celcius" but I can't find a way for the Replace function to detect and replace this specific caracter.

    Here's an exemple that I am using for many other caracters and words replacement: ResSommaire = Replace(ResSommaire ,"05h00","à cinq heure. ") and this works fine but if iI try the below line (where DevTemp is 7.7°C)

    ResTemp = Replace(DevTemp,"°C"," degré celsius")

    the results of ResTemp is always 7.7°C and not 7.7 degré celsius as I would expect it to be

    Any idea ?
    thanks

    #2
    You could try: ResTemp = Replace( DevTemp, Chr(176), " degré celsius")
    Mike____________________________________________________________ __________________
    HS3 Pro Edition 3.0.0.548, NUC i3

    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

    Comment


      #3
      Uncle Michael Unfortunatly, your solution gives the same results, the " ° " caracter is still not recognised by the replace function with chr(176), thanks for the try

      Comment


        #4
        You need to examine the actual device string code as it may contain html code for the degree symbol. If you have my device viewer & documenter installed, you can use the advanced view to see the string (code) being used.

        Example below:

        Click image for larger version  Name:	Capture.PNG Views:	0 Size:	40.3 KB ID:	1505645

        Alternatively, you can right-click on the web page and select 'view source' and try to find it there.
        Jon

        Comment


          #5
          jon00 I just tried the device viewer utility and there does not seem to be any HTML:

          Click image for larger version

Name:	aaa.JPG
Views:	247
Size:	6.5 KB
ID:	1505784

          I guess I need to find a way to enter ResTemp = Replace(DevTemp,"°C"," degré celsius") in the script but if I enter this line in the script editor, the editor immediatly change the ° by " ° "

          Comment


            #6
            ° is the html code for the character °

            You will need to use a standard text editor rather than Homeseer's which is limited.
            Jon

            Comment


              #7
              jon00 thank you so much, I edited the file with Note entered ResTemp = Replace(DevTemp,"°C"," degré celsius") and now it works.

              Comment


                #8
                Originally posted by goldriver View Post
                jon00 thank you so much, I edited the file with Note entered ResTemp = Replace(DevTemp,"°C"," degré celsius") and now it works.
                Just remember NOT to open it in Homeseer's editor or it will be modified!
                Jon

                Comment


                  #9
                  What about using this instead ℃
                  it’s the actual degree C symbol

                  HTML code is
                  &#8451
                  You have to add a ; after the code above.


                  Roger D

                  Comment

                  Working...
                  X