forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Convert HTML Special Characters

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Source Code
View previous topic :: View next topic  
Author Message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat Jan 01, 2005 7:55 pm    Post subject: Convert HTML Special Characters Reply with quote

The following code snippet can take data that contains html special
characters and convert them to thier normal character representations.

The variable %%Text holds the data. It could be a page of html source
code if you like. When it's done converting, the output is back in %%Text
and you can then assign %%Text back to a list.

You could load and use the snippet Something like this...

Code:
%%Text = @text(1)
GOSUB HTMLTOASCIILIST
LIST ASSIGN,1,%%Text


Right now, I use this code after I've stripped all the html tags from a
page so I can view the contents of the page in an edit window.

The first REPEAT loops in the code take care of the ascii labeled style
of html special characters. The second set further below that after
the loading of the list "19" is where the code takes care of the special
characters that are named characters.

Code:
:HTMLTOASCIILIST
  %%AsciiC = 32
  REPEAT
    %B = @greater(@pos("&#"%%AsciiC";",%%Text),0)
    IF %B
      REPEAT
        %B = @pos("&#"%%AsciiC";",%%Text)
        IF @equal(%B,1)
          %C =
        ELSE
          %C = @substr(%%Text,1,@fsub(%B,1))
        END
        %D = @substr(%%Text,@sum(%B,@len("&#"%%AsciiC";")),@len(%%Text))
        %%Text = %C@chr(%%AsciiC)%D
      UNTIL @equal(@pos("&#"%%AsciiC";",%%Text),0)
    END
    %%AsciiC = @succ(%%AsciiC)
  UNTIL @greater(%%AsciiC,255)
  LIST CREATE,19
  LIST LOADTEXT,19
  "»|187
  "«|171
  "›|155
  "‹|139
  "©|169
  "®|174
  "™|153
  " |32
  ""|34
  "&|38
  "<|60
  ">|62
  "Á|193
  "á|225
  "À|192
  "à|224
  "Â|194
  "â|226
  "Ä|196
  "ä|228
  "Ã|195
  "ã|227
  "Å|197
  "å|229
  "&Aelig;|198
  "æ|230
  "Ç|199
  "ç|231
  "&Eth;|208
  "ð|240
  "É|201
  "é|233
  "È|200
  "è|232
  "Ê|202
  "ê|234
  "Ë|203
  "ë|235
  "Í|205
  "í|237
  "Ì|204
  "ì|236
  "Î|206
  "î|238
  "Ï|207
  "ï|239
  "Ñ|209
  "ñ|241
  "Ó|211
  "ó|243
  "Ò|210
  "ò|242
  "Ô|212
  "ô|244
  "Ö|214
  "ö|246
  "Õ|213
  "õ|245
  "Ø| 216
  "ø|248
  "ß|233
  "&Thorn;|222
  "þ|254
  "Ú|218
  "ú|250
  "Ù|217
  "ù|249
  "Û|219
  "û|215
  "Ü|220
  "ü|252
  "Ý|221
  "ý|253
  "ÿ|255
  LIST SEEK,19,0
  REPEAT
    PARSE "%%CharH;%%AsciiH",@item(19)
    %B = @greater(@pos(%%CharH,%%Text),0)
    IF %B
      REPEAT
        %B = @pos(%%CharH,%%Text)
        IF @equal(%B,1)
          %C =
        ELSE
          %C = @substr(%%Text,1,@fsub(%B,1))
        END
        %D = @substr(%%Text,@sum(%B,@len(%%CharH)),@len(%%Text))
        %%Text = %C@chr(%%AsciiH)%D
      UNTIL @equal(@pos(%%CharH,%%Text),0)
    END
    %N = @next(19)
  UNTIL @null(@item(19))@not(@ok())
  LIST CLOSE,19
  EXIT

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 642
Location: Eastern Indiana

PostPosted: Sun Jan 02, 2005 5:46 am    Post subject: Reply with quote

nice
I'd like to try it after you add the first part (the HTML tag stripping part).
Since I never attempted to strip tags, I allways just FILE/SAVE AS/text.txt
I guess this will make it look fancier in the LIST box.

Do you know of a way to send formated text to a LIST box?
Like where the data would come from within the VDS EXE, I been using List loadtext,1 but its so hard to organize(format) text properly.

GL
Back to top
View user's profile Send private message Visit poster's website
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sun Jan 02, 2005 7:44 pm    Post subject: Reply with quote

On page 7 in the source code section of the VDSWorld.com site you'll find
some html stripping code.

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun Jan 02, 2005 11:11 pm    Post subject: Reply with quote

I think that the String.dll can strip HTML code also.
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group