fix: can't open as image diagrams with non-Latin1 characters (#2402)

This commit is contained in:
Shlomo authored and GitHub committed 2025-04-08 16:12:21 -07:00
1 parent 1961583eb6
commit b7c03af9ac
2 files changed
+9 -1

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"claude-dev": patch
---
fix: open diagrams with non-Latin characters (Hebrew, Arabic etc.)
@@ -174,7 +174,10 @@ async function svgToPng(svgEl: SVGElement): Promise<string> {
const serializer = new XMLSerializer()
const svgString = serializer.serializeToString(svgClone)
const svgDataUrl = "data:image/svg+xml;base64," + btoa(decodeURIComponent(encodeURIComponent(svgString)))
const encoder = new TextEncoder()
const bytes = encoder.encode(svgString)
const base64 = btoa(Array.from(bytes, (byte) => String.fromCharCode(byte)).join(""))
const svgDataUrl = `data:image/svg+xml;base64,${base64}`
return new Promise((resolve, reject) => {
const img = new Image()