Entity encode

From Kolmafia
Revision as of 01:09, 17 May 2010 by imported>Bale (Created page with '{{ #vardefine:name|entity_encode}}{{ #vardefine:return_type|string}}{{ #vardefine:aggregate|no}}{{ FunctionPage| name={{#var:name}}| function_category=Relay Browser Functions| …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Function Syntax

string entity_encode(string value )

  • string value  to be encoded.

Used for converting text that might contain special characters such as ampersands and angle brackets so that it can safely be displayed in HTML.

Code Sample

Read the form fields in a UI script for use later.

void write_option(string label, string value, string current) {
   write("<option value='");
   write(value);
   write("'");
   if (value == current) {
      write(" selected");
   }
   write(">");
   write(entity_encode(label));
   writeln("</option>");
}

See Also

form_field() | entity_decode() | write() | writeln()

More Information

See User Interface Scripts for more information.