feat: add UTF-8 conversion for email body and enhance MailViewer processing

This commit is contained in:
Lyz Coote
2026-02-05 15:26:52 +01:00
parent ad1116db14
commit d9e848d3f4
5 changed files with 79 additions and 11 deletions

17
app.go
View File

@@ -10,8 +10,11 @@ import (
"strings"
"sync"
"time"
"unicode/utf8"
"golang.org/x/sys/windows/registry"
"golang.org/x/text/encoding/charmap"
"golang.org/x/text/transform"
"emly/backend/utils"
internal "emly/backend/utils/mail"
@@ -517,3 +520,17 @@ func (a *App) IsDebuggerRunning() bool {
}
return utils.IsDebugged()
}
func (a *App) ConvertToUTF8(s string) string {
if utf8.ValidString(s) {
return s
}
// If invalid UTF-8, assume Windows-1252 (superset of ISO-8859-1)
decoder := charmap.Windows1252.NewDecoder()
decoded, _, err := transform.String(decoder, s)
if err != nil {
return s // Return as-is if decoding fails
}
return decoded
}