mirror of
https://github.com/rwinkhart/backtone.git
synced 2026-08-29 21:36:51 -04:00
Add unicode interpretation; add example for cached VideoCardz feed
This commit is contained in:
+16
-1
@@ -72,5 +72,20 @@ func stitchFields(info []string, connectors []string, indices []int8) string {
|
||||
output.WriteString(info[indices[i]])
|
||||
}
|
||||
}
|
||||
return output.String()
|
||||
return interpretUnicode(output.String())
|
||||
}
|
||||
|
||||
func interpretUnicode(s string) string {
|
||||
// match \uXXXX patterns
|
||||
r := regexp.MustCompile(`\\u([0-9a-fA-F]{4})`)
|
||||
result := r.ReplaceAllStringFunc(s, func(match string) string {
|
||||
// extract the hex value
|
||||
hexStr := match[2:] // skip the \u part
|
||||
code, err := strconv.ParseInt(hexStr, 16, 32)
|
||||
if err != nil {
|
||||
return match // if parsing fails, return original
|
||||
}
|
||||
return string(rune(code))
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user