# now who wrote this one...cant remember
# you can get a more complete table @ tcllib1.7/htmlparse/htmlparse.tcl

##Find and unescape HTML escape characters of the form &xxx;
proc uneschtml {text} {
   if {![regexp & $text]} { set text } else {
      regsub -all {([][$\\])} $text {\\\1} text
      regsub -all {&#([0-9][0-9]?[0-9]?);?} $text {[format \%c [scan \1 \%d tmp;set tmp]]} text
      regsub -all {&([a-zA-Z]+);?} $text {[uneschtml_map \1]} text
      subst -novariables $text
   }
}
## Convert an HTML escape sequence into character (used only by uneschtml):
proc uneschtml_map {text {unknown ?}} { global eschtml_map
   if {[info exists eschtml_map($text)]} { set eschtml_map($text) } else { set unknown }
}
## ISO Latin-1 escape characters/codes (used by uneschtml_map):
array set eschtml_map {
   lt <   gt >   amp &   quot \"   copy \xa9
   reg \xae   ob \x7b   cb \x7d   nbsp \xa0
   nbsp \xa0 iexcl \xa1 cent \xa2 pound \xa3 curren \xa4
   yen \xa5 brvbar \xa6 sect \xa7 uml \xa8 copy \xa9
   ordf \xaa laquo \xab not \xac shy \xad reg \xae
   hibar \xaf deg \xb0 plusmn \xb1 sup2 \xb2 sup3 \xb3
   acute \xb4 micro \xb5 para \xb6 middot \xb7 cedil \xb8
   sup1 \xb9 ordm \xba raquo \xbb frac14 \xbc frac12 \xbd
   frac34 \xbe iquest \xbf Agrave \xc0 Aacute \xc1 Acirc \xc2
   Atilde \xc3 Auml \xc4 Aring \xc5 AElig \xc6 Ccedil \xc7
   Egrave \xc8 Eacute \xc9 Ecirc \xca Euml \xcb Igrave \xcc
   Iacute \xcd Icirc \xce Iuml \xcf ETH \xd0 Ntilde \xd1
   Ograve \xd2 Oacute \xd3 Ocirc \xd4 Otilde \xd5 Ouml \xd6
   times \xd7 Oslash \xd8 Ugrave \xd9 Uacute \xda Ucirc \xdb
   Uuml \xdc Yacute \xdd THORN \xde szlig \xdf agrave \xe0
   aacute \xe1 acirc \xe2 atilde \xe3 auml \xe4 aring \xe5
   aelig \xe6 ccedil \xe7 egrave \xe8 eacute \xe9 ecirc \xea
   euml \xeb igrave \xec iacute \xed icirc \xee iuml \xef
   eth \xf0 ntilde \xf1 ograve \xf2 oacute \xf3 ocirc \xf4
   otilde \xf5 ouml \xf6 divide \xf7 oslash \xf8 ugrave \xf9
   uacute \xfa ucirc \xfb uuml \xfc yacute \xfd thorn \xfe
   yuml \xff
}

