Jump to content
Sign in to follow this  
Ascend4nt

Best way to translate text to HTML code?

Recommended Posts

Ascend4nt

Hi, I recently found a need to do conversion of regular (ANS) strings to HTML code, replacing all the special tag items with special codes (example: "<" will be converted to "&lt;"). What I'm wondering is - is there an easier way to do this then the code below?

Note the example text here is: special//?<>chara¢cters&"in&strings;''<woo\>

and its echoed to the console in converted format preceded by 'Body HTML:'

Thanks!

_IEErrorHandlerRegister ()
$oIE = _IECreateEmbedded ()
GUICreate("Embedded Web control Test", 100, 100,0,0)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 10, 50, 50)

_IENavigate($oIE,'about:blank')
_IEAction ($oIE, "refresh")
; Send just the bare minimum elements of a webpage
_IEDocWriteHTML ($oIE, "<html><body>"&@CRLF&"</body>"&@CRLF&"</html>")

$oBody = _IETagNameGetCollection($oIE, "body", 0)
_IEDocInsertText($oBody,'special//?<>chara¢cters&"in&strings;'&"''"&'<woo\>',"afterbegin")

$sBodyText=_IEBodyReadHTML($oIE)
; Necessary because the returned code can contain quotes, which will mess things up for me:
$sBodyText=StringReplace(StringReplace($sBodyText,'"',"&quot;"),"'","&"&"#092;")
ConsoleWrite("Body HTML:"&@CRLF&$sBodyText&@CRLF)

*edit: 'refresh' in the wrong spot. (not even sure where/when its necessary?)

Edited by ascendant

Share this post


Link to post
Share on other sites
oMBRa

you mean this _INetExplorerCapable?

Share this post


Link to post
Share on other sites
Ascend4nt

oMBRa,

No, that's for making usable URL's - that wouldn't work in creating HTML code. But hey, thanks for the effort - I didn't even know what that function did until I just tried it (documentation is a little lackluster for it) :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.