function htmlentities(text)
{
text = text.replace(/"/g,'&quot;'); // 34 22
text = text.replace(/&/g,'&amp;'); // 38 26
text = text.replace(/\'/g,'&#39;'); // 39 27
text = text.replace(/</g,'&lt;'); // 60 3C
text = text.replace(/>/g,'&gt;'); // 62 3E
text = text.replace(/\^/g,'&circ;'); // 94 5E
text = text.replace(//g,'&lsquo;'); // 145 91
text = text.replace(//g,'&rsquo;'); // 146 92
text = text.replace(//g,'&ldquo;'); // 147 93
text = text.replace(//g,'&rdquo;'); // 148 94
text = text.replace(//g,'&bull;'); // 149 95
text = text.replace(//g,'&ndash;'); // 150 96
text = text.replace(//g,'&mdash;'); // 151 97
text = text.replace(//g,'&tilde;'); // 152 98
text = text.replace(//g,'&trade;'); // 153 99
text = text.replace(//g,'&scaron;'); // 154 9A
text = text.replace(//g,'&rsaquo;'); // 155 9B
text = text.replace(//g,'&oelig;'); // 156 9C
text = text.replace(//g,'&#357;'); // 157 9D
text = text.replace(//g,'&#382;'); // 158 9E
text = text.replace(//g,'&Yuml;'); // 159 9F
// text = text.replace(/ /g,'&nbsp;'); // 160 A0
text = text.replace(//g,'&iexcl;'); // 161 A1
text = text.replace(//g,'&cent;'); // 162 A2
text = text.replace(//g,'&pound;'); // 163 A3
//text = text.replace(/ /g,'&curren;'); // 164 A4
text = text.replace(//g,'&yen;'); // 165 A5
text = text.replace(//g,'&brvbar;'); // 166 A6
text = text.replace(//g,'&sect;'); // 167 A7
text = text.replace(//g,'&uml;'); // 168 A8
text = text.replace(//g,'&copy;'); // 169 A9
text = text.replace(//g,'&ordf;'); // 170 AA
text = text.replace(//g,'&laquo;'); // 171 AB
text = text.replace(//g,'&not;'); // 172 AC
text = text.replace(//g,'&shy;'); // 173 AD
text = text.replace(//g,'&reg;'); // 174 AE
text = text.replace(//g,'&macr;'); // 175 AF
text = text.replace(//g,'&deg;'); // 176 B0
text = text.replace(//g,'&plusmn;'); // 177 B1
text = text.replace(//g,'&sup2;'); // 178 B2
text = text.replace(//g,'&sup3;'); // 179 B3
text = text.replace(//g,'&acute;'); // 180 B4
text = text.replace(//g,'&micro;'); // 181 B5
text = text.replace(//g,'&para'); // 182 B6
text = text.replace(//g,'&middot;'); // 183 B7
text = text.replace(//g,'&cedil;'); // 184 B8
text = text.replace(//g,'&sup1;'); // 185 B9
text = text.replace(//g,'&ordm;'); // 186 BA
text = text.replace(//g,'&raquo;'); // 187 BB
text = text.replace(//g,'&frac14;'); // 188 BC
text = text.replace(//g,'&frac12;'); // 189 BD
text = text.replace(//g,'&frac34;'); // 190 BE
text = text.replace(//g,'&iquest;'); // 191 BF
text = text.replace(//g,'&Agrave;'); // 192 C0
text = text.replace(//g,'&Aacute;'); // 193 C1
text = text.replace(//g,'&Acirc;'); // 194 C2
text = text.replace(//g,'&Atilde;'); // 195 C3
text = text.replace(//g,'&Auml;'); // 196 C4
text = text.replace(//g,'&Aring;'); // 197 C5
text = text.replace(//g,'&AElig;'); // 198 C6
text = text.replace(//g,'&Ccedil;'); // 199 C7
text = text.replace(//g,'&Egrave;'); // 200 C8
text = text.replace(//g,'&Eacute;'); // 201 C9
text = text.replace(//g,'&Ecirc;'); // 202 CA
text = text.replace(//g,'&Euml;'); // 203 CB
text = text.replace(//g,'&Igrave;'); // 204 CC
text = text.replace(//g,'&Iacute;'); // 205 CD
text = text.replace(//g,'&Icirc;'); // 206 CE
text = text.replace(//g,'&Iuml;'); // 207 CF
text = text.replace(//g,'&ETH;'); // 208 D0
text = text.replace(//g,'&Ntilde;'); // 209 D1
text = text.replace(//g,'&Ograve;'); // 210 D2
text = text.replace(//g,'&Oacute;'); // 211 D3
text = text.replace(//g,'&Ocirc;'); // 212 D4
text = text.replace(//g,'&Otilde;'); // 213 D5
text = text.replace(//g,'&Ouml;'); // 214 D6
text = text.replace(//g,'&times;'); // 215 D7
text = text.replace(//g,'&Oslash;'); // 216 D8
text = text.replace(//g,'&Ugrave;'); // 217 D9
text = text.replace(//g,'&Uacute;'); // 218 DA
text = text.replace(//g,'&Ucirc;'); // 219 DB
text = text.replace(//g,'&Uuml;'); // 220 DC
text = text.replace(//g,'&Yacute;'); // 221 DD
text = text.replace(//g,'&THORN;'); // 222 DE
text = text.replace(//g,'&szlig;'); // 223 DF
text = text.replace(//g,'&aacute;'); // 224 E0
text = text.replace(//g,'&aacute;'); // 225 E1
text = text.replace(//g,'&acirc;'); // 226 E2
text = text.replace(//g,'&atilde;'); // 227 E3
text = text.replace(//g,'&auml;'); // 228 E4
text = text.replace(//g,'&aring;'); // 229 E5
text = text.replace(//g,'&aelig;'); // 230 E6
text = text.replace(//g,'&ccedil;'); // 231 E7
text = text.replace(//g,'&egrave;'); // 232 E8
text = text.replace(//g,'&eacute;'); // 233 E9
text = text.replace(//g,'&ecirc;'); // 234 EA
text = text.replace(//g,'&euml;'); // 235 EB
text = text.replace(//g,'&igrave;'); // 236 EC
text = text.replace(//g,'&iacute;'); // 237 ED
text = text.replace(//g,'&icirc;'); // 238 EE
text = text.replace(//g,'&iuml;'); // 239 EF
text = text.replace(//g,'&eth;'); // 240 F0
text = text.replace(//g,'&ntilde;'); // 241 F1
text = text.replace(//g,'&ograve;'); // 242 F2
text = text.replace(//g,'&oacute;'); // 243 F3
text = text.replace(//g,'&ocirc;'); // 244 F4
text = text.replace(//g,'&otilde;'); // 245 F5
text = text.replace(//g,'&ouml;'); // 246 F6
text = text.replace(//g,'&divide;'); // 247 F7
text = text.replace(//g,'&oslash;'); // 248 F8
text = text.replace(//g,'&ugrave;'); // 249 F9
text = text.replace(//g,'&uacute;'); // 250 FA
text = text.replace(//g,'&ucirc;'); // 251 FB
text = text.replace(//g,'&uuml;'); // 252 FC
text = text.replace(//g,'&yacute;'); // 253 FD
text = text.replace(//g,'&thorn;'); // 254 FE
text = text.replace(//g,'&yuml;'); // 255 FF
return text;
}