From 773b371cb4084720f3e729c2b4fc6a95a5547c09 Mon Sep 17 00:00:00 2001 From: Cliford Date: Fri, 8 Oct 2021 19:51:35 +0530 Subject: [PATCH] fixed unicode truncation bug --- spotify-widget/spotify.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spotify-widget/spotify.lua b/spotify-widget/spotify.lua index bd2309f..0eb302a 100644 --- a/spotify-widget/spotify.lua +++ b/spotify-widget/spotify.lua @@ -16,8 +16,8 @@ local GET_SPOTIFY_STATUS_CMD = 'sp status' local GET_CURRENT_SONG_CMD = 'sp current' local function ellipsize(text, length) - return (text:len() > length and length > 0) - and text:sub(0, length - 3) .. '...' + return (utf8.len(text) > length and length > 0) + and text:sub(0, utf8.offset(text, length - 2) - 1) .. '...' or text end