Convert HTML entities

Help with writing and running scripts

Convert HTML entities

Postby gieri » Tue Nov 27, 2007 6:02 pm

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
User avatar
gieri
Newbie
 
Posts: 4
Joined: Tue Nov 27, 2007 12:00 am

Re: Convert HTML entities

Postby jorrasdk » Tue Nov 27, 2007 11:40 pm

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)
User avatar
jorrasdk
Master
Master
 
Posts: 275
Joined: Mon Mar 19, 2007 11:00 pm
Location: Denmark

Re: Convert HTML entities

Postby gieri » Wed Nov 28, 2007 2:31 pm

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

Regards.

gieri
User avatar
gieri
Newbie
 
Posts: 4
Joined: Tue Nov 27, 2007 12:00 am

Re: Convert HTML entities

Postby jorrasdk » Wed Nov 28, 2007 8:29 pm

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 [ [ "—","—" ] ,
 [ "–","–" ] ,
 [ "-","­" ] ,
 [ "\"",""" ] ,
 [ "&","&" ] ,
 [ "ˆ","ˆ" ] ,
 [ "¡","¡" ] ,
 [ "¦","¦" ] ,
 [ "¨","¨" ] ,
 [ "¯","¯" ] ,
 [ "´","´" ] ,
 [ "¸","¸" ] ,
 [ "¿","¿" ] ,
 [ "˜","˜" ] ,
 [ "‘","‘" ] ,
 [ "’","’" ] ,
 [ "‚","‚" ] ,
 [ "“","“" ] ,
 [ "”","”" ] ,
 [ "„","„" ] ,
 [ "‹","‹" ] ,
 [ "›","›" ] ,
 [ "<","&lt;" ] ,
 [ ">","&gt;" ] ,
 [ "±","&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;" ] ];
}
User avatar
jorrasdk
Master
Master
 
Posts: 275
Joined: Mon Mar 19, 2007 11:00 pm
Location: Denmark

Re: Convert HTML entities

Postby gieri » Mon Dec 03, 2007 1:45 pm

Great!!

Many thanks, jorrasdk. Big help for me ;)

Regards.

gieri
User avatar
gieri
Newbie
 
Posts: 4
Joined: Tue Nov 27, 2007 12:00 am


Return to Scripts