How To Do: Translate HTML codes to normal text
I have a script program that I tried using the following code:
Code:
'
'
$value =~ tr/+/ /;
$value =~ tr/%21/!/;
$value =~ tr/%22/"/;
$value =~ tr/%25/%/;
$value =~ tr/%26/&/;
$value =~ tr/%28/(/;
$value =~ tr/%29/)/;
$value =~ tr/%2C/,/;
$value =~ tr/%2F/|/;
$value =~ tr/%3C/>/;
$value =~ tr/%3D/=/;
$value =~ tr/%3E/</;
'
'
Unfortunately it does'nt do what I though it would do.
I want to take each HTML code like %xx and change it to the real character.
For example %3E = "<" and %3C = ">"
Anyone know how to do this?
Re: How To Do: Translate HTML codes to normal text
Re: How To Do: Translate HTML codes to normal text
Re: How To Do: Translate HTML codes to normal text
Quote:
Originally Posted by
Hackoo
That would OK but my code is not VBScript
Re: How To Do: Translate HTML codes to normal text
Quote:
Originally Posted by
Hackoo
Well, don't know about this one. It doesn't really give me the script code I need
Re: How To Do: Translate HTML codes to normal text
The code I posted translates a one for one character.
For example
This code line takes all occurances of plus (+) sign and changes them to blank or spaces
$value =~ tr/+/ /;
What this will do is change all % to !, then all 2 to ! then all 1 to ! so I wind up with !!!
$value =~ tr/%21/!/;
but that is not what I need. I need %21 to be changed to only one character, !
Re: How To Do: Translate HTML codes to normal text
Here, try this:
Code:
Private Declare Function UrlUnescapeW Lib "shlwapi.dll" (ByVal pszURL As Long, ByVal pszUnescaped As Long, ByRef pcchUnescaped As Long, ByVal dwFlags As Long) As Long
Public Function URLDecode(ByRef sURL As String) As String
Const INTERNET_MAX_URL_LENGTH = 2083&, E_POINTER = &H80004003
Dim ChrCnt As Long
ChrCnt = INTERNET_MAX_URL_LENGTH + 1&
Do: URLDecode = Space$(ChrCnt - 1&)
Loop While UrlUnescapeW(StrPtr(sURL), StrPtr(URLDecode), ChrCnt, 0&) = E_POINTER
If ChrCnt < Len(URLDecode) Then URLDecode = Left$(URLDecode, ChrCnt)
ChrCnt = InStr(URLDecode, "+")
While ChrCnt
Mid$(URLDecode, ChrCnt) = " "
ChrCnt = InStr(ChrCnt, URLDecode, "+")
Wend
End Function
Note:
MSDN says "input strings cannot be longer than INTERNET_MAX_URL_LENGTH".
Re: How To Do: Translate HTML codes to normal text
This has nothing to do with Microsoft, or Windows. This is a script program that runs on the web server. It's a Perl script program.
Re: How To Do: Translate HTML codes to normal text
Then it should have been posted in the correct forum...
like the XML, HTML, Javascript, Web and CSS one... it even specifies that "Topics include: Perl, Cold Fusion, etc. (Java, ASP & VB Script and PHP are separate)"
I'll ask a mod to move it....
-tg
Re: How To Do: Translate HTML codes to normal text
I didn't see the other forum. I posted here because I read this:
This forum is the place to post all your questions about using the Internet within your applications. Topics include: writing components for ASP (classic), VB Script, and more.
Guess I didn't look far enough.
Re: How To Do: Translate HTML codes to normal text