Commit: f944ab80cf51e028c7ec6102151bc8e80cb5ccf5
Parent: 2f35fb601e254f7fbf927ffc47591afa490394be
Author: Ren Tatsumoto
Date: Wed, 4 Nov 2020 19:45:03 +0300
use str:sub for ascii strings
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/subs2srs.lua b/subs2srs.lua
@@ -275,6 +275,11 @@ do
local bytes_per_char = contains_non_latin_letters(str) and #'車' or #'z'
local limit_chars = math.floor(limit_bytes / bytes_per_char)
+
+ if limit_chars == limit_bytes then
+ return str:sub(1, limit_bytes)
+ end
+
local ret = subprocess {
'awk',
'-v', string.format('str=%s', str),