Entity encode

From Kolmafia
Revision as of 16:49, 14 October 2014 by imported>Ulti (expanding the "see also" to keep the url_encode, url_decode, entity_encode, entity_decode functions together as you'd expect)
(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() | url_encode() | url_decode()

More Information

See User Interface Scripts for more information.