diff --git a/functions/strings.xml b/functions/strings.xml index ab901bff36..db3fc707bc 100644 --- a/functions/strings.xml +++ b/functions/strings.xml @@ -576,16 +576,21 @@ $pieces = explode (" ", $pizza); get_html_translation_table int table + int quote_style get_html_translation_table will return the translation table that is used internally for htmlspecialchars and - htmlentities. Ther are two new defines + htmlentities. There are two new defines (HTML_ENTITIES, HTML_SPECIALCHARS) that allow you to - specify the table you want. + specify the table you want. And as in the + htmlspecialchars and + htmlentities functions you can optionally specify the + quote_style you are working with. The default is ENT_COMPAT mode. See + the description of these modes in htmlspecialchars. Translation Table Example @@ -745,13 +750,19 @@ $original = strtr ($str, $trans); string htmlentities string string + int quote_style This function is identical to htmlspecialchars in all ways, except that all characters which have HTML character entity equivalents are - translated into these entities. + translated into these entities. Like htmlspecialchars(), it takes an + optional second argument which indicates what should be done with + single and double quotes. ENT_COMPAT (the default) will only convert + double-quotes and leave single-quotes alone. ENT_QUOTES will convert + both double and single quotes, and ENT_NOQUOTES will leave both double + and single quotes unconverted. At present, the ISO-8859-1 character set is used. @@ -776,13 +787,14 @@ $original = strtr ($str, $trans); string htmlspecialchars string string + int quote_style Certain characters have special significance in HTML, and should be represented by HTML entities if they are to preserve their meanings. This function returns a string with some of these - conversions made; the four translations made are those most + conversions made; the translations made are those most useful for everyday web programming. If you require all HTML character entities to be translated, use htmlentities instead. @@ -790,7 +802,13 @@ $original = strtr ($str, $trans); This function is useful in preventing user-supplied text from containing HTML markup, such as in a message board or guest book - application. + application. The optional second argument, quote_style, tells the + function what to do with single and double quote characters. The + default mode, ENT_COMPAT, is the backwards compatible mode which only + translates the double-quote character and leaves the single-quote + untranslated. If ENT_QUOTES is set, both single and double quotes + are translated and if ENT_NOQUOTES is set neither single nor double quotes + are translated. The translations performed are: @@ -802,7 +820,12 @@ $original = strtr ($str, $trans); - '"' (double quote) becomes '&quot;' + '"' (double quote) becomes '&quot;' when ENT_NOQUOTES is not set. + + + + + ''' (single quote) becomes '&#039;' only when ENT_QUOTES is set. @@ -816,6 +839,12 @@ $original = strtr ($str, $trans); + + <function>htmlspecialchars</function> example + +$new = htmlspecialchars("Test", ENT_QUOTES); + + Note that this functions does not translate anything beyond what