Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Server.HTMLEncode equivalent for VFP?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Applications Internet
Divers
Thread ID:
00456699
Message ID:
00456906
Vues:
25
>>
>>Can anbody recommend how to use Server.HTMLEncode for IIS (assuming either IIS or PWS is installed on the same PC) from within VFP, or otherwise get the equivalent functionality of Server.HTMLEncode from within VFP? In other words, I need a text-to-HTML encoding function that translates ">" and "<" and other special characters to the appropriate > and < syntax. Thanks.
>>

>
>I usually use two functions for this (mainly for displaying HTML and code
>in an HTML document):
>
>
>************************************************************************
>Function FixHTMLForDisplay
>************************************************************************
>#IF .F.
>*:Help Documentation
>*:Topic:
>wwUtils::FixHTMLForDisplay
>
>*:Description:
>This method fixes up HTML for display. Takes HTML and XML tags and converts
>them to HTML displayable characters (< for < for example).
>
>*:Parameters:
><>lcHTML<>
>HTML to fix up.
>
>*:Returns:
>Fixed up HTML
>*:ENDHELP
>#ENDIF
>************************************************************************
>LPARAMETER lcHTML
>
>lcHTML = STRTRAN(lcHTML,"<","<")
>lcHTML = STRTRAN(lcHTML,">",">")
>lcHTML = STRTRAN(lcHTML,["],""")
>
>RETURN lcHTML
>
>
>************************************************************************
>FUNCTION DisplayMemo
>**************************
>*** Function: Fixes linebreaks into HTML breaks
and


>*** Pass: lcHTML - HTML to fix
>*** Return: Fixed HTML
>*************************************************************************
>LPARAMETER lcHTML
>
>lcHTML = STRTRAN(lcHTML,CHR(13)+CHR(10),CHR(13))
>lcHTML = STRTRAN(lcHTML,CHR(10),CHR(13))
>lcHTML = STRTRAN(lcHTML,CHR(13)+CHR(13),"

")
>
>RETURN STRTRAN(lcHTML,CHR(13),"
")
>* FixHTMLLineBreaks
>

************************************************************************
Function FixHTMLForDisplay
************************************************************************
#IF .F.
*:Help Documentation
*:Topic: wwUtils::FixHTMLForDisplay
*:Description:
This method fixes up HTML for display. Takes HTML and XML tags and converts
them to HTML displayable characters (&lt; for &lt; for example).

*:Parameters:
&lt;&lt;b&gt;&gt;lcHTML&lt;&lt;/b&gt;&gt;
HTML to fix up.

*:Returns:
Fixed up HTML
*:ENDHELP
#ENDIF
************************************************************************
LPARAMETER lcHTML

lcHTML = STRTRAN(lcHTML,"&lt;","&lt;")
lcHTML = STRTRAN(lcHTML,"&gt;","&gt;")
lcHTML = STRTRAN(lcHTML,["],""")

RETURN lcHTML


************************************************************************
FUNCTION DisplayMemo
**************************
***  Function: Fixes linebreaks into HTML breaks &lt;br&gt; and &lt;p&gt;
***      Pass: lcHTML  -   HTML to fix
***    Return: Fixed HTML
*************************************************************************
LPARAMETER lcHTML

lcHTML = STRTRAN(lcHTML,CHR(13)+CHR(10),CHR(13))
lcHTML = STRTRAN(lcHTML,CHR(10),CHR(13))
lcHTML = STRTRAN(lcHTML,CHR(13)+CHR(13),"&lt;p&gt;")

RETURN STRTRAN(lcHTML,CHR(13),"&lt;br&gt;")
* FixHTMLLineBreaks
&lt;/code&gt;
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform