Closed dequis closed 7 years ago
Oddly enough there's no glib function for this
g_utf8_substring()
?
g_utf8_substring()
is available since 2.30 (somewhat above the current requirements i'd like to have) and doesn't check length before truncating, which is risky. I got the idea of using g_utf8_offset_to_pointer()
from there though.
Fixes issues with invalid utf8 in servers that start their names with unicode characters (like emoji)
Oddly enough there's no glib function for this, and bitlbee's truncate_utf8() does the opposite of what we need to do here (truncates by bytes instead of characters and ensures those bytes are valid utf8)
Fixes #85
I should probably figure out what to do to avoid writing invalid utf8 to the config in the first place (like some sort of write-time validation? but what can i do if it's not valid?), but that's harder than fixing this side.