| Author | |
| Committer | |
| Tree | ddb343dc5a969c70cbaeaad4b914134f9c35bfde |
Fix UTF-8 character rendering in logs This commit fixes a bug where multi-byte UTF-8 characters in the log view were being displayed as a sequence of individual, incorrect characters. The issue was caused by improperly decoding the base64-encoded log data from the server. The `atob()` function was used directly, which decodes to a raw byte string, not a UTF-8 string. This broke the encoding for any character outside the basic ASCII range. The fix introduces a proper UTF-8 decoding step after the base64 decoding. It uses the `decodeURIComponent(escape(...))` idiom to correctly interpret the byte stream as UTF-8, ensuring all characters render correctly in the browser. | |
diff --git a/assets/sai.js b/assets/sai.js index 838c068..2d0306c 100644 --- a/assets/sai.js +++ b/assets/sai.js @@ -1647,8 +1647,12 @@ function ws_open_sai() break; case "com-warmcat-sai-logs": - var s1 = atob(jso.log), s = hsanitize(s1), li, + try { + var s1 = decodeURIComponent(escape(atob(jso.log))), s = hsanitize(s1), li, en = "", yo, dh, ce, tn = ""; + } catch (e) { + break; + } if (!tfirst) tfirst = jso.timestamp;