convert html to characters by using pxwsa
 

convert html to characters by using pxwsa

Started by Leun, 02 February, 2007, 14:47:35

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Leun

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;

for a,b in ConvertHTML do   
    if sDirector then  
         sDirector= string.gsub(sDirector,a,b);    
    end	  
end

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


greetz

bastya_elvtars

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.

Leun

Quote from: bastya_elvtars on 02 February, 2007, 17:16:41
Isn't this easier and faster with string.gfind("(%&%#.+%:)") and hashing?

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

bastya_elvtars

Everything could have been anything else and it would have just as much meaning.

Leun

something like this?

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

bastya_elvtars

Everything could have been anything else and it would have just as much meaning.

SMF spam blocked by CleanTalk