BindWebviewCallback does not not work when the returned string contains umlauts.
But no error messages in PB or WebView console.
Example Code:
Code: Select all
Procedure ComputeJS(JsonParameters$)
; Protected string$ = ~"{ \"text\": \"ABC\"}"
Protected string$ = ~"{ \"text\": \"äöüÄÖÜß^âá\"}"
; Protected string$ = ~"{ \"text\": \""+EscapeString("ABC", #PB_String_EscapeJSON)+~"\"}"
; Protected string$ = ~"{ \"text\": \""+EscapeString("äöüÄÖÜß^âá", #PB_String_EscapeJSON)+~"\"}"
Debug "compute"
ProcedureReturn UTF8(string$)
EndProcedure
OpenWindow(0, 100, 100, 400, 400, "Hello", #PB_Window_SystemMenu)
WebViewGadget(0, 0, 0, 400, 400, #PB_WebView_Debug)
SetGadgetItemText(0, #PB_WebView_HtmlCode,
~"<button id=\"compute\">Compute</button>\n"+
~"<div>Result of computation: <span id=\"compute-result\">0</span></div>\n"+
~"<script charset='utf-8'>\n"+
~" const [computeElement, computeResultElement] =\n"+
~" document.querySelectorAll(\"#compute, #compute-result\");\n"+
~" document.addEventListener(\"DOMContentLoaded\", () => {\n"+
~" computeElement.addEventListener(\"click\", () => {\n"+
~" computeElement.disabled = true;\n"+
~" window.compute(6, 7).then(result => {\n"+
~" console.log('result: ', result.text);"+
~" computeResultElement.textContent = result.text;\n"+
~" computeElement.disabled = false;\n"+
~" });\n"+
~" });\n"+
~" });\n"+
~"</script>")
BindWebViewCallback(0, "compute", @ComputeJS())
WebViewExecuteScript(0, "document.getElementById('compute').textContent = 'äöüÄÖÜß^âá';")
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
(WebViewExecuteScript works fine with umlauts btw)
Tested with PB 6.12 Beta4 x64 on Windows10 x64

