Function encodeAsHtml

  • Encode the provided string to a safe HTML form, converting the base &, <, >, \" and ' characters into their HTML encoded representations

    Parameters

    • value: string

      The string value to be converted into a HTML safe form

    Returns string

    The converted string as HTML

    0.9.0

    encodeAsHtml("HelloDarkness"); // "HelloDarkness"
    encodeAsHtml("Hello Darkness"); // "Hello Darkness"
    encodeAsHtml("hello.Darkness"); // "hello.Darkness"
    encodeAsHtml("hello-Darkness"); // "hello-Darkness"
    encodeAsHtml("hello_Darkness"); // "hello_Darkness"
    encodeAsHtml("abc-123"); // "abc-123"
    encodeAsHtml("0abc0"); // "0abc0"
    encodeAsHtml("\"HelloDarkness\""); // "&quot;HelloDarkness&quot;"
    encodeAsHtml("\"Hello Darkness\""); // "&quot;Hello Darkness&quot;"
    encodeAsHtml("\"hello Darkness\""); // "&quot;hello Darkness&quot;"
    encodeAsHtml("\"hello Darkness\""); // "&quot;hello Darkness&quot;"
    encodeAsHtml("\"hello .,#<[]>Darkness\""); // "&quot;hello .,#&lt;[]&gt;Darkness&quot;"
    encodeAsHtml("<script src=\"javascript:alert('Hello');\"></script>"); // "&lt;script src=&quot;javascript:alert(&#39;Hello&#39;);&quot;&gt;&lt;/script&gt;"