-
Feb 9th, 2013, 05:37 PM
#1
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?
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Feb 11th, 2013, 02:59 PM
#2
Lively Member
Re: How To Do: Translate HTML codes to normal text
-
Feb 11th, 2013, 03:30 PM
#3
Lively Member
Re: How To Do: Translate HTML codes to normal text
-
Feb 11th, 2013, 03:42 PM
#4
Re: How To Do: Translate HTML codes to normal text
Originally Posted by Hackoo
That would OK but my code is not VBScript
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Feb 11th, 2013, 03:43 PM
#5
Re: How To Do: Translate HTML codes to normal text
Originally Posted by Hackoo
Well, don't know about this one. It doesn't really give me the script code I need
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Feb 11th, 2013, 03:47 PM
#6
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, !
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Feb 12th, 2013, 05:46 PM
#7
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".
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Feb 12th, 2013, 06:03 PM
#8
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.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Feb 12th, 2013, 09:13 PM
#9
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
-
Feb 12th, 2013, 10:39 PM
#10
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.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Feb 14th, 2013, 06:35 AM
#11
Re: How To Do: Translate HTML codes to normal text
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|