What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » HTML entities(?)

HTML entities(?)
Author: Message:
pollolibredegrasa
Full Member
***

Avatar
formerly fatfreechicken

Posts: 483
Reputation: 34
35 / Male / Flag
Joined: May 2005
O.P. HTML entities(?)
OK, so I have written a small script that gets a slogan from http://www.sloganizer.net using whatever input the user wants.

However, if the user enters certain characters, it will return the special code for them in the string.

For example, If the user enters a ", it shows in the debugger as: \"

Is there any way to convert these back to their corresponding characters? I assume there probably is using regular expression, but I just can't get my head around them, so any help would be appreciated.

This post was edited on 12-03-2006 at 04:46 PM by pollolibredegrasa.
;p

[Image: chickennana.gif] Vaccy is my thin twin! [Image: chickennana.gif]
12-03-2006 04:45 PM
Profile PM Find Quote Report
mickael9
Full Member
***


Posts: 117
Reputation: 3
33 / Male / Flag
Joined: Jul 2005
RE: HTML entities(?)
code:
var htmlentities = {
    '"'   : '"',
    ' '   : ' ',
    '''   : '\'',
    '&'    : '&',
    '\\\''     : '\''
}
String.prototype.htmldecode = function()
{
    var sRet = this;
   
    for (var sKey in htmlentities)
    {
        sRet = sRet.replace(new RegExp(sKey, 'g'), htmlentities[sKey]);
    }
   
    return sRet;
}

var decodedText = myText.htmldecode();

This post was edited on 12-04-2006 at 07:18 PM by mickael9.
12-03-2006 06:18 PM
Profile PM Web Find Quote Report
pollolibredegrasa
Full Member
***

Avatar
formerly fatfreechicken

Posts: 483
Reputation: 34
35 / Male / Flag
Joined: May 2005
O.P. RE: HTML entities(?)
Thanks, it sort of works, but it still leaves a \ before the character. Is there a way to remove that too?
;p

[Image: chickennana.gif] Vaccy is my thin twin! [Image: chickennana.gif]
12-04-2006 05:57 PM
Profile PM Find Quote Report
mickael9
Full Member
***


Posts: 117
Reputation: 3
33 / Male / Flag
Joined: Jul 2005
RE: HTML entities(?)
Edited ...
12-04-2006 07:18 PM
Profile PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: HTML entities(?)
quote:
Originally posted by mickael9
code:
var htmlentities = {
    '"'   : '"',
    ' '   : ' ',
    '''   : '\'',
    '&'    : '&',
    '\\\''     : '\''
}

multiply that list be several thousand possible entities and you have your complete script.

Otherwise such a function will always leave some entities behind.

Just to say that making something like this requires a extremely huge list...
With the result that your for...loop and the use of an object creator for each element is going to slow down your script a hell of a lot.

For situations like this, I suggest you actually dish regular expressions and make your own string manipulation routines.

Or better yet, use existing ActiveX objects which might do this job for you (I'm thinking about the XML object and that stuff)

This post was edited on 12-05-2006 at 12:25 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-05-2006 12:18 AM
Profile PM Find Quote Report
pollolibredegrasa
Full Member
***

Avatar
formerly fatfreechicken

Posts: 483
Reputation: 34
35 / Male / Flag
Joined: May 2005
O.P. RE: RE: RE: HTML entities(?)
quote:
Originally posted by CookieRevised
Or better yet, use existing ActiveX objects which might do this job for you (I'm thinking about the XML object and that stuff)

Thanks Cookie, I had a look at the XML object and got it to partially work. Some things don't get replaced however, such as £ for £. Is there a reason for this (like, these are not supported by XML or something?)
;p

[Image: chickennana.gif] Vaccy is my thin twin! [Image: chickennana.gif]
12-06-2006 03:08 PM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: HTML entities(?)
I can't think of any reason other than that specific activex not supporting HTML 3.2 tags (which is already pretty old by now, so... eeek)...

Or XHTML doesn't support that specific entity (which again seems very strange though)?

the pound entitiy is part of the ISO Latin/1 8859-1 list, so it should be supported :/

sorry. :(

This post was edited on 12-07-2006 at 12:44 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-07-2006 12:38 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On