Title:
Bug 84118:Add a function for converting characters into their HTML entity equivalentHTMLEditFormat() already converts characters with special meaning in HTML into their entity equivalent (similar to the PHP fun
| View in TrackerStatus/Resolution/Reason: Closed/Deferred/
Reporter/Name(from Bugbase): Sebastian Zartner / Sebastian Zartner (Sebastian Zartner)
Created: 09/10/2010
Components: Language, Functions
Versions: 9.0.1
Failure Type: Unspecified
Found In Build/Fixed In Build: 0000 /
Priority/Frequency: Trivial / Some users will encounter
Locale/System: English / Platforms All
Vote Count: 0
Problem:
Add a function for converting characters into their HTML entity equivalentHTMLEditFormat() already converts characters with special meaning in HTML into their entity equivalent (similar to the PHP function htmlspecialchars()), but there's currently no function, that converts all characters with an HTML equivalent into that entities (htmlentities() in PHP).Such a function would be useful to avoid encoding problems.This could either be an enhancement for the function HTMLEditFormat() (as optional parameter) or done in a new function like HTMLFormat() or HTMLEncode(). I'd prefer the latter, because this could also combine HTMLEditFormat() and HTMLCodeFormat() in one function in the medium term and would give the possibility to create a function HTMLDecode(), that does the opposite (in PHP this is html_entity_decode()).The syntax of this function could look like so:HTMLEncode(string [, type, quote_style, charset])type = Type of encoding (for a first implementation "all" as value would be enough, later "edit" and "code" could be added)quote_style = Defines whether single and/or double quotes shall also be encoded (possible values: "double", "single", "both" and "none"; default: "double")charset = Charset used for the conversion (possible values: all supported charsets; default: "utf-8")
Method:
<!--- After calling HTMLEncode() "HTMLString" will contain "bÄé§"<'µ¥©" ---><cfset HTMLString = HTMLEncode("bÄé§"<'µ¥©")>
Result:
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3042141
External Customer Info:
External Company:
External Customer Name: Sebastian Zartner
External Customer Email: 4E7365D64550DB12992015D5
External Test Config: 09/10/2010
Attachments:
Comments: