fix: use os.LookupEnv for LANG check in ensureUTF8Env

Replace manual string slicing with os.LookupEnv which is more idiomatic
and correctly handles the edge case where LANG is set to an empty string.
This commit is contained in:
Varun Chawla 2026-02-22 20:42:00 -08:00
commit b34587efda
No known key found for this signature in database

View file

@ -13,12 +13,10 @@ import (
// an ASCII-compatible encoding that mangles non-ASCII text.
func ensureUTF8Env() []string {
env := os.Environ()
for _, e := range env {
if len(e) > 5 && e[:5] == "LANG=" {
return env
}
if _, ok := os.LookupEnv("LANG"); !ok {
env = append(env, "LANG=en_US.UTF-8")
}
return append(env, "LANG=en_US.UTF-8")
return env
}
func (f *Frontend) ClipboardGetText() (string, error) {