Author Topic: convert html to characters by using pxwsa  (Read 3241 times)

0 Members and 1 Guest are viewing this topic.

Offline Leun

  • Scripter
  • Fulll Member
  • ******
  • Posts: 64
  • Karma: +7/-0
convert html to characters by using pxwsa
« on: 02 February, 2007, 14:47:35 »
Hi,

In one of my scripts I use pxwsa to get info from a website.
But some characters had a html code, so you need to convert it, what cost lots of time,
So a little help;

Code: [Select]
for a,b in ConvertHTML do   
    if sDirector then 
         sDirector= string.gsub(sDirector,a,b);   
    end  
end

ConvertHTML = {   
 ["""] = '"', ["&"] = "&", ["À"] = "?", ["Á"] = "?",
 ["Â"] = "?", ["Ã"] = "?", ["Ä"] = "?", ["Å"] = "?",
 ["Æ"] = "?", ["Ç"] = "?", ["È"] = "?", ["É"] = "?",
 ["Ê"] = "?", ["Ë"] = "?", ["Ì"] = "?", ["Í"] = "?",
 ["Î"] = "?", ["Ï"] = "?", ["Ð"] = "?", ["Ñ"] = "?",
 ["Ò"] = "?", ["Ó"] = "?", ["Ô"] = "?", ["Õ"] = "?",
 ["Ö"] = "?", ["Ø"] = "?", ["Ù"] = "?", ["Ú"] = "?",
 ["Û"] = "?", ["Ü"] = "?", ["Ý"] = "?", ["Þ"] = "?",
 ["ß"] = "?", ["à"] = "?", ["á"] = "?", ["â"] = "?",
 ["ã"] = "?", ["ä"] = "?", ["å"] = "?", ["æ"] = "?",
 ["ç"] = "?", ["è"] = "?", ["é"] = "?", ["ê"] = "?",
 ["ë"] = "?", ["ì"] = "?", ["í"] = "?", ["î"] = "?",
 ["ï"] = "?", ["ð"] = "?", ["ð"] = "?", ["ñ"] = "?",
 ["ò"] = "?", ["ó"] = "?", ["ô"] = "?", ["õ"] = "?",
 ["ö"] = "?", ["÷"] = "?", ["ø"] = "?", ["ù"] = "?",
 ["ú"] = "?", ["û"] = "?", ["ü"] = "?", ["ý"] = "?",
 ["þ"] = "?", ["ÿ"] = "?",
}

greetz

PtokaX forum

convert html to characters by using pxwsa
« on: 02 February, 2007, 14:47:35 »

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 744
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: convert html to characters by using pxwsa
« Reply #1 on: 02 February, 2007, 17:16:41 »
Isn't this easier and faster with string.gfind("(%&%#.+%:)") and hashing?
Everything could have been anything else and it would have just as much meaning.

Offline Leun

  • Scripter
  • Fulll Member
  • ******
  • Posts: 64
  • Karma: +7/-0
Re: convert html to characters by using pxwsa
« Reply #2 on: 03 February, 2007, 11:58:11 »
Isn't this easier and faster with string.gfind("(%&%#.+%:)") and hashing?

Yes you're right, thnx for the tip  :)

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 744
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: convert html to characters by using pxwsa
« Reply #3 on: 03 February, 2007, 15:01:52 »
Care to show us your work then? :)
Everything could have been anything else and it would have just as much meaning.

Offline Leun

  • Scripter
  • Fulll Member
  • ******
  • Posts: 64
  • Karma: +7/-0
Re: convert html to characters by using pxwsa
« Reply #4 on: 03 February, 2007, 16:29:38 »
something like this?

Code: [Select]
ConvertFeed = function(fFeed)
for txt in string.gfind(fFeed,"(%&%#.+%;)") do
for a,b in ConvertHTML do   
fFeed = string.gsub(txt,a,b)   
end  
end
return fFeed
end

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 744
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: convert html to characters by using pxwsa
« Reply #5 on: 03 February, 2007, 20:10:43 »
No, fFeed[txt]
Everything could have been anything else and it would have just as much meaning.

PtokaX forum

Re: convert html to characters by using pxwsa
« Reply #5 on: 03 February, 2007, 20:10:43 »