Merge pull request #302 from clifordjoshy/master

Fixes issue while printing song names containing certain unicode characters.
This commit is contained in:
streetturtle 2021-10-14 16:02:52 -04:00 committed by GitHub
commit 173ef2fab3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,8 +16,8 @@ local GET_SPOTIFY_STATUS_CMD = 'sp status'
local GET_CURRENT_SONG_CMD = 'sp current' local GET_CURRENT_SONG_CMD = 'sp current'
local function ellipsize(text, length) local function ellipsize(text, length)
return (text:len() > length and length > 0) return (utf8.len(text) > length and length > 0)
and text:sub(0, length - 3) .. '...' and text:sub(0, utf8.offset(text, length - 2) - 1) .. '...'
or text or text
end end