DWSTRING.JScriptproperty
Converts the DWSTRING content into a safe JavaScript expression for use with WebView2 ExecuteScript.
Syntax
PROPERTY DWSTRING.JScript () AS STRING
Description
Converts the DWSTRING content into a safe JavaScript expression for use with WebView2 ExecuteScript.
WebView2 requires UTF-8 text when passing strings to JavaScript. This property takes the internal UTF-8 byte sequence of the DWSTRING and generates a JavaScripy expression of the form: This guarantees that any Unicode text (including accents, symbols and emojis) is transmitted correctly to JavaScript without escaping issues, broken quotes, or encoding mismatches.
The user can therefore pass DWSTRING values directly to ExecuteScript without worrying about UTF-8 handling or manual escaping.
Examples
new TextDecoder('utf-8').decode(Uint8Array.from([b1,b2,b3,...]))
m_pWebView->ExecuteScript("console.log(" & myString.JScript & ");")
Reference
- Include file
DWSTRING.inc - Defined in AfxNova/DWSTRING.inc:353
- Documented in String Management/DWSTRING Class.md
- Topic: DWSTRING Class