| | 213 | |
| | 214 | QString urlEncode(const QString& s, const QString& encoding) |
| | 215 | { |
| | 216 | QString enc=encoding.toLower(); |
| | 217 | if (enc.isEmpty() || enc=="utf8" || enc=="utf-8") |
| | 218 | return QString(QUrl::toPercentEncoding(s)); |
| | 219 | |
| | 220 | QString dst; |
| | 221 | QTextCodec* codec=QTextCodec::codecForName(encoding.toAscii()); |
| | 222 | QByteArray arr; |
| | 223 | if (codec) |
| | 224 | arr=codec->fromUnicode(s); |
| | 225 | else |
| | 226 | arr=s.toUtf8(); |
| | 227 | int l=arr.length(); |
| | 228 | for (int i=0; i<l; ++i) |
| | 229 | { |
| | 230 | char ch=arr.at(i); |
| | 231 | if ((ch >= 'A' && ch<='A') || (ch>='a' && ch<='a') || (ch>='0' && ch<='9') |
| | 232 | || ch=='~' || ch=='~' || ch=='.' || ch=='-') |
| | 233 | { |
| | 234 | dst.append(ch); |
| | 235 | } |
| | 236 | else |
| | 237 | { |
| | 238 | QString num; |
| | 239 | num.setNum((unsigned char)ch,16); |
| | 240 | num=num.rightJustified(2,QChar('0')); |
| | 241 | dst.append("%"+num); |
| | 242 | } |
| | 243 | } |
| | 244 | return dst; |
| | 245 | } |
| | 246 | |
| | 247 | void populateHtmlMap() |
| | 248 | { |
| | 249 | htmlMap.insert("nbsp"," "); |
| | 250 | htmlMap.insert("iexcl", QChar(161)); |
| | 251 | htmlMap.insert("cent", QChar(162)); |
| | 252 | htmlMap.insert("pound", QChar(163)); |
| | 253 | htmlMap.insert("curren", QChar(164)); |
| | 254 | htmlMap.insert("yen", QChar(165)); |
| | 255 | htmlMap.insert("brvbar", QChar(166)); |
| | 256 | htmlMap.insert("sect", QChar(167)); |
| | 257 | htmlMap.insert("uml", QChar(168)); |
| | 258 | htmlMap.insert("copy", QChar(169)); |
| | 259 | htmlMap.insert("ordf", QChar(170)); |
| | 260 | htmlMap.insert("laquo", QChar(171)); |
| | 261 | htmlMap.insert("raquo", QChar(187)); |
| | 262 | htmlMap.insert("not", QChar(172)); |
| | 263 | htmlMap.insert("shy", QChar(173)); |
| | 264 | htmlMap.insert("reg", QChar(174)); |
| | 265 | htmlMap.insert("macr", QChar(175)); |
| | 266 | htmlMap.insert("deg", QChar(176)); |
| | 267 | htmlMap.insert("plusmn", QChar(177)); |
| | 268 | htmlMap.insert("sup2", QChar(178)); |
| | 269 | htmlMap.insert("sup3", QChar(179)); |
| | 270 | htmlMap.insert("acute", QChar(180)); |
| | 271 | htmlMap.insert("micro", QChar(181)); |
| | 272 | htmlMap.insert("para", QChar(182)); |
| | 273 | htmlMap.insert("middot", QChar(183)); |
| | 274 | htmlMap.insert("cedil", QChar(184)); |
| | 275 | htmlMap.insert("sup1", QChar(185)); |
| | 276 | htmlMap.insert("ordm", QChar(186)); |
| | 277 | htmlMap.insert("frac14", QChar(188)); |
| | 278 | htmlMap.insert("frac12", QChar(189)); |
| | 279 | htmlMap.insert("frac34", QChar(190)); |
| | 280 | htmlMap.insert("iquest", QChar(191)); |
| | 281 | htmlMap.insert("Agrave", QChar(192)); |
| | 282 | htmlMap.insert("Aacute", QChar(193)); |
| | 283 | htmlMap.insert("Acirc", QChar(194)); |
| | 284 | htmlMap.insert("Atilde", QChar(195)); |
| | 285 | htmlMap.insert("Auml", QChar(196)); |
| | 286 | htmlMap.insert("Aring", QChar(197)); |
| | 287 | htmlMap.insert("AElig", QChar(198)); |
| | 288 | htmlMap.insert("Ccedil", QChar(199)); |
| | 289 | htmlMap.insert("Egrave", QChar(200)); |
| | 290 | htmlMap.insert("Eacute", QChar(201)); |
| | 291 | htmlMap.insert("Ecirc", QChar(202)); |
| | 292 | htmlMap.insert("Euml", QChar(203)); |
| | 293 | htmlMap.insert("Igrave", QChar(204)); |
| | 294 | htmlMap.insert("Iacute", QChar(205)); |
| | 295 | htmlMap.insert("Icirc", QChar(206)); |
| | 296 | htmlMap.insert("Iuml", QChar(207)); |
| | 297 | htmlMap.insert("ETH", QChar(208)); |
| | 298 | htmlMap.insert("Ntilde", QChar(209)); |
| | 299 | htmlMap.insert("Ograve", QChar(210)); |
| | 300 | htmlMap.insert("Oacute", QChar(211)); |
| | 301 | htmlMap.insert("Ocirc", QChar(212)); |
| | 302 | htmlMap.insert("Otilde", QChar(213)); |
| | 303 | htmlMap.insert("Ouml", QChar(214)); |
| | 304 | htmlMap.insert("times", QChar(215)); |
| | 305 | htmlMap.insert("Oslash", QChar(216)); |
| | 306 | htmlMap.insert("Ugrave", QChar(217)); |
| | 307 | htmlMap.insert("Uacute", QChar(218)); |
| | 308 | htmlMap.insert("Ucirc", QChar(219)); |
| | 309 | htmlMap.insert("Uuml", QChar(220)); |
| | 310 | htmlMap.insert("Yacute", QChar(221)); |
| | 311 | htmlMap.insert("THORN", QChar(222)); |
| | 312 | htmlMap.insert("szlig", QChar(223)); |
| | 313 | htmlMap.insert("agrave", QChar(224)); |
| | 314 | htmlMap.insert("aacute", QChar(225)); |
| | 315 | htmlMap.insert("acirc", QChar(226)); |
| | 316 | htmlMap.insert("atilde", QChar(227)); |
| | 317 | htmlMap.insert("auml", QChar(228)); |
| | 318 | htmlMap.insert("aring", QChar(229)); |
| | 319 | htmlMap.insert("aelig", QChar(230)); |
| | 320 | htmlMap.insert("ccedil", QChar(231)); |
| | 321 | htmlMap.insert("egrave", QChar(232)); |
| | 322 | htmlMap.insert("eacute", QChar(233)); |
| | 323 | htmlMap.insert("ecirc", QChar(234)); |
| | 324 | htmlMap.insert("euml", QChar(235)); |
| | 325 | htmlMap.insert("igrave", QChar(236)); |
| | 326 | htmlMap.insert("iacute", QChar(237)); |
| | 327 | htmlMap.insert("icirc", QChar(238)); |
| | 328 | htmlMap.insert("iuml", QChar(239)); |
| | 329 | htmlMap.insert("eth", QChar(240)); |
| | 330 | htmlMap.insert("ntilde", QChar(241)); |
| | 331 | htmlMap.insert("ograve", QChar(242)); |
| | 332 | htmlMap.insert("oacute", QChar(243)); |
| | 333 | htmlMap.insert("ocirc", QChar(244)); |
| | 334 | htmlMap.insert("otilde", QChar(245)); |
| | 335 | htmlMap.insert("ouml", QChar(246)); |
| | 336 | htmlMap.insert("divide", QChar(247)); |
| | 337 | htmlMap.insert("oslash", QChar(248)); |
| | 338 | htmlMap.insert("ugrave", QChar(249)); |
| | 339 | htmlMap.insert("uacute", QChar(250)); |
| | 340 | htmlMap.insert("ucirc", QChar(251)); |
| | 341 | htmlMap.insert("uuml", QChar(252)); |
| | 342 | htmlMap.insert("yacute", QChar(253)); |
| | 343 | htmlMap.insert("thorn", QChar(254)); |
| | 344 | htmlMap.insert("yuml", QChar(255)); |
| | 345 | |
| | 346 | htmlMap.insert("fnof", QChar(402)); |
| | 347 | |
| | 348 | htmlMap.insert("Alpha", QChar(913)); |
| | 349 | htmlMap.insert("Beta", QChar(914)); |
| | 350 | htmlMap.insert("Gamma", QChar(915)); |
| | 351 | htmlMap.insert("Delta", QChar(916)); |
| | 352 | htmlMap.insert("Epsilon", QChar(917)); |
| | 353 | htmlMap.insert("Zeta", QChar(918)); |
| | 354 | htmlMap.insert("Eta", QChar(919)); |
| | 355 | htmlMap.insert("Theta", QChar(920)); |
| | 356 | htmlMap.insert("Iota", QChar(921)); |
| | 357 | htmlMap.insert("Kappa", QChar(922)); |
| | 358 | htmlMap.insert("Lambda", QChar(923)); |
| | 359 | htmlMap.insert("Mu", QChar(924)); |
| | 360 | htmlMap.insert("Nu", QChar(925)); |
| | 361 | htmlMap.insert("Xi", QChar(926)); |
| | 362 | htmlMap.insert("Omicron", QChar(927)); |
| | 363 | htmlMap.insert("Pi", QChar(928)); |
| | 364 | htmlMap.insert("Rho", QChar(929)); |
| | 365 | htmlMap.insert("Sigma", QChar(931)); |
| | 366 | htmlMap.insert("Tau", QChar(932)); |
| | 367 | htmlMap.insert("Upsilon", QChar(933)); |
| | 368 | htmlMap.insert("Phi", QChar(934)); |
| | 369 | htmlMap.insert("Chi", QChar(935)); |
| | 370 | htmlMap.insert("Psi", QChar(936)); |
| | 371 | htmlMap.insert("Omega", QChar(937)); |
| | 372 | htmlMap.insert("alpha", QChar(945)); |
| | 373 | htmlMap.insert("beta", QChar(946)); |
| | 374 | htmlMap.insert("gamma", QChar(947)); |
| | 375 | htmlMap.insert("delta", QChar(948)); |
| | 376 | htmlMap.insert("epsilon", QChar(949)); |
| | 377 | htmlMap.insert("zeta", QChar(950)); |
| | 378 | htmlMap.insert("eta", QChar(951)); |
| | 379 | htmlMap.insert("theta", QChar(952)); |
| | 380 | htmlMap.insert("iota", QChar(953)); |
| | 381 | htmlMap.insert("kappa", QChar(954)); |
| | 382 | htmlMap.insert("lambda", QChar(955)); |
| | 383 | htmlMap.insert("mu", QChar(956)); |
| | 384 | htmlMap.insert("nu", QChar(957)); |
| | 385 | htmlMap.insert("xi", QChar(958)); |
| | 386 | htmlMap.insert("omicron", QChar(959)); |
| | 387 | htmlMap.insert("pi", QChar(960)); |
| | 388 | htmlMap.insert("rho", QChar(961)); |
| | 389 | htmlMap.insert("sigmaf", QChar(962)); |
| | 390 | htmlMap.insert("sigma", QChar(963)); |
| | 391 | htmlMap.insert("tau", QChar(964)); |
| | 392 | htmlMap.insert("upsilon", QChar(965)); |
| | 393 | htmlMap.insert("phi", QChar(966)); |
| | 394 | htmlMap.insert("chi", QChar(967)); |
| | 395 | htmlMap.insert("psi", QChar(968)); |
| | 396 | htmlMap.insert("omega", QChar(969)); |
| | 397 | htmlMap.insert("thetasy", QChar(977)); |
| | 398 | htmlMap.insert("upsih", QChar(978)); |
| | 399 | htmlMap.insert("piv", QChar(982)); |
| | 400 | |
| | 401 | htmlMap.insert("bull", QChar(8226)); |
| | 402 | htmlMap.insert("hellip", QChar(8230)); |
| | 403 | htmlMap.insert("prime", QChar(8242)); |
| | 404 | htmlMap.insert("Prime", QChar(8243)); |
| | 405 | htmlMap.insert("oline", QChar(8254)); |
| | 406 | htmlMap.insert("frasl", QChar(8260)); |
| | 407 | |
| | 408 | htmlMap.insert("weierp", QChar(8472)); |
| | 409 | htmlMap.insert("image", QChar(8465)); |
| | 410 | htmlMap.insert("real", QChar(8476)); |
| | 411 | htmlMap.insert("trade", QChar(8482)); |
| | 412 | htmlMap.insert("alefsym", QChar(8501)); |
| | 413 | |
| | 414 | htmlMap.insert("larr", QChar(8592)); |
| | 415 | htmlMap.insert("uarr", QChar(8593)); |
| | 416 | htmlMap.insert("rarr", QChar(8594)); |
| | 417 | htmlMap.insert("darr", QChar(8595)); |
| | 418 | htmlMap.insert("harr", QChar(8596)); |
| | 419 | htmlMap.insert("crarr", QChar(8629)); |
| | 420 | htmlMap.insert("lArr", QChar(8656)); |
| | 421 | htmlMap.insert("uArr", QChar(8657)); |
| | 422 | htmlMap.insert("rArr", QChar(8658)); |
| | 423 | htmlMap.insert("dArr", QChar(8659)); |
| | 424 | htmlMap.insert("hArr", QChar(8660)); |
| | 425 | |
| | 426 | htmlMap.insert("forall", QChar(8704)); |
| | 427 | htmlMap.insert("part", QChar(8706)); |
| | 428 | htmlMap.insert("exist", QChar(8707)); |
| | 429 | htmlMap.insert("empty", QChar(8709)); |
| | 430 | htmlMap.insert("nabla", QChar(8711)); |
| | 431 | htmlMap.insert("isin", QChar(8712)); |
| | 432 | htmlMap.insert("notin", QChar(8713)); |
| | 433 | htmlMap.insert("ni", QChar(8715)); |
| | 434 | htmlMap.insert("prod", QChar(8719)); |
| | 435 | htmlMap.insert("sum", QChar(8721)); |
| | 436 | htmlMap.insert("minus", QChar(8722)); |
| | 437 | htmlMap.insert("lowast", QChar(8727)); |
| | 438 | htmlMap.insert("radic", QChar(8730)); |
| | 439 | htmlMap.insert("prop", QChar(8733)); |
| | 440 | htmlMap.insert("infin", QChar(8734)); |
| | 441 | htmlMap.insert("ang", QChar(8736)); |
| | 442 | htmlMap.insert("and", QChar(8743)); |
| | 443 | htmlMap.insert("or", QChar(8744)); |
| | 444 | htmlMap.insert("cap", QChar(8745)); |
| | 445 | htmlMap.insert("cup", QChar(8746)); |
| | 446 | htmlMap.insert("int", QChar(8747)); |
| | 447 | htmlMap.insert("there4", QChar(8756)); |
| | 448 | htmlMap.insert("sim", QChar(8764)); |
| | 449 | htmlMap.insert("cong", QChar(8773)); |
| | 450 | htmlMap.insert("asymp", QChar(8776)); |
| | 451 | htmlMap.insert("ne", QChar(8800)); |
| | 452 | htmlMap.insert("equiv", QChar(8801)); |
| | 453 | htmlMap.insert("le", QChar(8804)); |
| | 454 | htmlMap.insert("ge", QChar(8805)); |
| | 455 | htmlMap.insert("sub", QChar(8834)); |
| | 456 | htmlMap.insert("sup", QChar(8835)); |
| | 457 | htmlMap.insert("nsub", QChar(8836)); |
| | 458 | htmlMap.insert("sube", QChar(8838)); |
| | 459 | htmlMap.insert("supe", QChar(8839)); |
| | 460 | htmlMap.insert("oplus", QChar(8853)); |
| | 461 | htmlMap.insert("otimes", QChar(8855)); |
| | 462 | htmlMap.insert("perp", QChar(8869)); |
| | 463 | htmlMap.insert("sdot", QChar(8901)); |
| | 464 | |
| | 465 | htmlMap.insert("lceil", QChar(8968)); |
| | 466 | htmlMap.insert("rceil", QChar(8969)); |
| | 467 | htmlMap.insert("lfloor", QChar(8970)); |
| | 468 | htmlMap.insert("rfloor", QChar(8971)); |
| | 469 | htmlMap.insert("lang", QChar(9001)); |
| | 470 | htmlMap.insert("rang", QChar(9002)); |
| | 471 | |
| | 472 | htmlMap.insert("loz", QChar(9674)); |
| | 473 | |
| | 474 | htmlMap.insert("spades", QChar(9824)); |
| | 475 | htmlMap.insert("clubs", QChar(9827)); |
| | 476 | htmlMap.insert("hearts", QChar(9829)); |
| | 477 | htmlMap.insert("diams", QChar(9830)); |
| | 478 | |
| | 479 | htmlMap.insert("quot", QChar(34)); |
| | 480 | htmlMap.insert("amp", QChar(38)); |
| | 481 | htmlMap.insert("lt", QChar(60)); |
| | 482 | htmlMap.insert("gt", QChar(62)); |
| | 483 | htmlMap.insert("OElig", QChar(338)); |
| | 484 | htmlMap.insert("oelig", QChar(339)); |
| | 485 | htmlMap.insert("Scaron", QChar(352)); |
| | 486 | htmlMap.insert("scaron", QChar(353)); |
| | 487 | htmlMap.insert("Yuml", QChar(376)); |
| | 488 | htmlMap.insert("circ", QChar(710)); |
| | 489 | htmlMap.insert("tilde", QChar(732)); |
| | 490 | htmlMap.insert("ensp", QChar(8194)); |
| | 491 | htmlMap.insert("emsp", QChar(8195)); |
| | 492 | htmlMap.insert("thinsp", QChar(8201)); |
| | 493 | htmlMap.insert("zwnj", QChar(8204)); |
| | 494 | htmlMap.insert("zwj", QChar(8205)); |
| | 495 | htmlMap.insert("lrm", QChar(8206)); |
| | 496 | htmlMap.insert("rlm", QChar(8207)); |
| | 497 | htmlMap.insert("ndash", QChar(8211)); |
| | 498 | htmlMap.insert("mdash", QChar(8212)); |
| | 499 | htmlMap.insert("lsquo", QChar(8216)); |
| | 500 | htmlMap.insert("rsquo", QChar(8217)); |
| | 501 | htmlMap.insert("sbquo", QChar(8218)); |
| | 502 | htmlMap.insert("ldquo", QChar(8220)); |
| | 503 | htmlMap.insert("rdquo", QChar(8221)); |
| | 504 | htmlMap.insert("bdquo", QChar(8222)); |
| | 505 | htmlMap.insert("dagger", QChar(8224)); |
| | 506 | htmlMap.insert("Dagger", QChar(8225)); |
| | 507 | htmlMap.insert("permil", QChar(8240)); |
| | 508 | htmlMap.insert("lsaquo", QChar(8249)); |
| | 509 | htmlMap.insert("rsaquo", QChar(8250)); |
| | 510 | htmlMap.insert("euro", QChar(8364)); |
| | 511 | } |