Lasso Soft Inc. > Home

[ string->encodehtml ]

Method

The [string->encodehtml] method has two forms. The first form takes no parameters, and the second takes two boolean parameters.

Both forms accept a string and change any reserved, illegal, and extended ASCII characters to their hexadecimal equivalent HTML entities.

The first form of [string->encodehtml] has the boolean parameters both set to false by default.

In the second form, the first boolean encodes line endings if True. The second boolean encodes "smart" if True. "Smart" encoding means not to encode the following characters: " & ' < > (double quotation mark, ampersand, single quotation mark, less than or left angle bracket, and greater than or right angle bracket, respectively).

The [string->encodehtml] method supersedes the [Encode_Smart] tag and the -EncodeSmart keyword parameter from Lasso 8.x and earlier. For backward compatability, the [encode_smart(text::any)] method uses the second form of encodeHtml where the boolean parameters are set to false and true, respectively.

  • Syntax
'String Value'->encodehtml
'String Value'->encodehtml(Boolean, Boolean)
Examples
  • Beginner

To change a string of characters to their hexadecimal equivalent HTML entities:

Use the [string->encodehtml] method. The following example uses the Swedish word for prawn sandwich wrapped with HTML tags, and returns the hexadecimal equivalent HTML entities.

Code

('<b>Räksmörgås</b>')->encodehtml

Result

&lt;b&gt;R&#228;ksm&#246;rg&#229;s&lt;/b&gt;

To change a string of characters to their hexadecimal equivalent HTML entities:

Use the [string->encodehtml] method. The following example uses the Swedish word for prawn sandwich wrapped with HTML tags, and returns the hexadecimal equivalent HTML entities.

Code

'<b>Räksmörgås</b>

Encode the previous line breaks and do not encode these: " & \' < >'->encodehtml(true, true)

Result

<b>Räksmörgås</b>&#xA;&#xA;Encode the previous line breaks and do not encode these: " & ' < >

Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft