ad_js_escape (public)

 ad_js_escape string

Defined in packages/acs-tcl/tcl/text-html-procs.tcl

Return supplied string with invalid javascript characters property escaped. This makes possible to use the string safely inside javascript code.

Parameters:
string (required)
Author:
Antonio Pisano

Partial Call Graph (max 5 caller/called nodes):
%3 test_ad_js_escape ad_js_escape (test acs-tcl) ad_js_escape ad_js_escape test_ad_js_escape->ad_js_escape

Testcases:
ad_js_escape
Source code:
    string map [list \n \\n \b \\b \f \\f \r \\r \t \\t \v \\v \" {\"} ' {\'}] $string

    # Escape quotes and backslashes (non greedy)
    #regsub -all -- {.??([^\\])?('|\"|\\)} $string {\1\\\2} string
    # Escape characters are replaced with their escape sequence
    #regsub -all -- {\b} $string {\\b} string
    #regsub -all -- {\f} $string {\\f} string
    #regsub -all -- {\n} $string {\\n} string
    #regsub -all -- {\r} $string {\\r} string
    #regsub -all -- {\t} $string {\\t} string
    #regsub -all -- {\v} $string {\\v} string

    #return $string
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: