Convert HTML entities

Convert HTML entities

11
Basic UserBasic User
11

    Nov 27, 2007#1

    Hello,

    how can I convert named HTML entities in chars and also reverse?

    Thanks for any hint.

    Regards

    gieri



    P.S. sorry for double post

    262
    MasterMaster
    262

      Nov 28, 2007#2

      From chars to HTML entities:

      - Activate the HTML toolbar: View - Views/Lists - Toolbars - HTML toolbar (checkmarked)

      - Select the text with special chars to be converted into HTML entities (Example: abcæøå)

      - Click the "HTML Text2html" icon - 3rd from the right in a standard HTML toolbar. Choose "normal" option in pop-up. (Example result: abcæøå)

      From HTML entities to chars:

      - No built-in options is available for that. I have a quick and dirty script for this that I'm willing post in this thread if you badly need to convert back. (Note: You will need UE version 13 and above to use a script)

      11
      Basic UserBasic User
      11

        Nov 28, 2007#3

        thanx for your help... yes, please post your script... I'm sure that other may has the same problems ;)

        Regards.

        gieri

        262
        MasterMaster
        262

          Nov 29, 2007#4

          This is how a quick and dirty script looks like ;-) - no comments in the code - have fun!

          Code: Select all

          UltraEdit.ueReOn();
          UltraEdit.activeDocument.top();
          UltraEdit.activeDocument.findReplace.matchCase = true;
          UltraEdit.activeDocument.findReplace.regExp = false;
          UltraEdit.activeDocument.findReplace.replaceAll = true;
          
          var convertEntities = getConversionTable();
          
          for (i in convertEntities) {
          UltraEdit.activeDocument.findReplace.replace(convertEntities[i][1],convertEntities[i][0]);
          }
          
          function getConversionTable() {
          return [ [ "—","—" ] ,
           [ "–","–" ] ,
           [ "-","­" ] ,
           [ "\"",""" ] ,
           [ "&","&" ] ,
           [ "ˆ","ˆ" ] ,
           [ "¡","¡" ] ,
           [ "¦","¦" ] ,
           [ "¨","¨" ] ,
           [ "¯","¯" ] ,
           [ "´","´" ] ,
           [ "¸","¸" ] ,
           [ "¿","¿" ] ,
           [ "˜","˜" ] ,
           [ "‘","‘" ] ,
           [ "’","’" ] ,
           [ "‚","‚" ] ,
           [ "“","“" ] ,
           [ "”","”" ] ,
           [ "„","„" ] ,
           [ "‹","‹" ] ,
           [ "›","›" ] ,
           [ "<","<" ] ,
           [ ">",">" ] ,
           [ "±","&plusmn;" ] ,
           [ "«","&laquo;" ] ,
           [ "»","&raquo;" ] ,
           [ "×","&times;" ] ,
           [ "÷","&divide;" ] ,
           [ "¢","&cent;" ] ,
           [ "£","&pound;" ] ,
           [ "¤","&curren;" ] ,
           [ "¥","&yen;" ] ,
           [ "§","&sect;" ] ,
           [ "©","&copy;" ] ,
           [ "¬","&not;" ] ,
           [ "®","&reg;" ] ,
           [ "°","&deg;" ] ,
           [ "µ","&micro;" ] ,
           [ "¶","&para;" ] ,
           [ "·","&middot;" ] ,
           [ "†","&dagger;" ] ,
           [ "‡","&Dagger;" ] ,
           [ "‰","&permil;" ] ,
           [ "€","&euro;" ] ,
           [ "¼","&frac14;" ] ,
           [ "½","&frac12;" ] ,
           [ "¾","&frac34;" ] ,
           [ "¹","&sup1;" ] ,
           [ "²","&sup2;" ] ,
           [ "³","&sup3;" ] ,
           [ "á","&aacute;" ] ,
           [ "Á","&Aacute;" ] ,
           [ "â","&acirc;" ] ,
           [ "Â","&Acirc;" ] ,
           [ "à","&agrave;" ] ,
           [ "À","&Agrave;" ] ,
           [ "å","&aring;" ] ,
           [ "Å","&Aring;" ] ,
           [ "ã","&atilde;" ] ,
           [ "Ã","&Atilde;" ] ,
           [ "ä","&auml;" ] ,
           [ "Ä","&Auml;" ] ,
           [ "ª","&ordf;" ] ,
           [ "æ","&aelig;" ] ,
           [ "Æ","&AElig;" ] ,
           [ "ç","&ccedil;" ] ,
           [ "Ç","&Ccedil;" ] ,
           [ "ð","&eth;" ] ,
           [ "Ð","&ETH;" ] ,
           [ "é","&eacute;" ] ,
           [ "É","&Eacute;" ] ,
           [ "ê","&ecirc;" ] ,
           [ "Ê","&Ecirc;" ] ,
           [ "è","&egrave;" ] ,
           [ "È","&Egrave;" ] ,
           [ "ë","&euml;" ] ,
           [ "Ë","&Euml;" ] ,
           [ "ƒ","&fnof;" ] ,
           [ "í","&iacute;" ] ,
           [ "Í","&Iacute;" ] ,
           [ "î","&icirc;" ] ,
           [ "Î","&Icirc;" ] ,
           [ "ì","&igrave;" ] ,
           [ "Ì","&Igrave;" ] ,
           [ "ï","&iuml;" ] ,
           [ "Ï","&Iuml;" ] ,
           [ "ñ","&ntilde;" ] ,
           [ "Ñ","&Ntilde;" ] ,
           [ "ó","&oacute;" ] ,
           [ "Ó","&Oacute;" ] ,
           [ "ô","&ocirc;" ] ,
           [ "Ô","&Ocirc;" ] ,
           [ "ò","&ograve;" ] ,
           [ "Ò","&Ograve;" ] ,
           [ "º","&ordm;" ] ,
           [ "ø","&oslash;" ] ,
           [ "Ø","&Oslash;" ] ,
           [ "õ","&otilde;" ] ,
           [ "Õ","&Otilde;" ] ,
           [ "ö","&ouml;" ] ,
           [ "Ö","&Ouml;" ] ,
           [ "œ","&oelig;" ] ,
           [ "Œ","&OElig;" ] ,
           [ "š","&scaron;" ] ,
           [ "Š","&Scaron;" ] ,
           [ "ß","&szlig;" ] ,
           [ "þ","&thorn;" ] ,
           [ "Þ","&THORN;" ] ,
           [ "ú","&uacute;" ] ,
           [ "Ú","&Uacute;" ] ,
           [ "û","&ucirc;" ] ,
           [ "Û","&Ucirc;" ] ,
           [ "ù","&ugrave;" ] ,
           [ "Ù","&Ugrave;" ] ,
           [ "ü","&uuml;" ] ,
           [ "Ü","&Uuml;" ] ,
           [ "ý","&yacute;" ] ,
           [ "Ý","&Yacute;" ] ,
           [ "ÿ","&yuml;" ] ,
           [ "Ÿ","&Yuml;" ] ];
          }

          11
          Basic UserBasic User
          11

            Dec 03, 2007#5

            Great!!

            Many thanks, jorrasdk. Big help for me ;)

            Regards.

            gieri