diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-08-23 12:42:37 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-08-23 12:42:37 +0900 |
| commit | 07d294425a98ee5d1e22d03e2b24ae2c76e487c0 (patch) | |
| tree | a6818f0d64438c5fdb88b00a35d944f80c056213 /mac/.config/mpv/script-modules/utf8/util.lua | |
| parent | 6fc28cdb3529ca8ee864cb5c41674cb0a4af72a1 (diff) | |
updates
Diffstat (limited to 'mac/.config/mpv/script-modules/utf8/util.lua')
| -rw-r--r-- | mac/.config/mpv/script-modules/utf8/util.lua | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/mac/.config/mpv/script-modules/utf8/util.lua b/mac/.config/mpv/script-modules/utf8/util.lua new file mode 100644 index 0000000..7723626 --- /dev/null +++ b/mac/.config/mpv/script-modules/utf8/util.lua @@ -0,0 +1,64 @@ +return function(utf8) + +function utf8.util.copy(obj, deep) + if type(obj) == 'table' then + local result = {} + if deep then + for k,v in pairs(obj) do + result[k] = utf8.util.copy(v, true) + end + else + for k,v in pairs(obj) do + result[k] = v + end + end + return result + else + return obj + end +end + +local function dump(val, tab) + tab = tab or '' + + if type(val) == 'table' then + utf8.config.logger('{\n') + for k,v in pairs(val) do + utf8.config.logger(tab .. tostring(k) .. " = ") + dump(v, tab .. '\t') + utf8.config.logger("\n") + end + utf8.config.logger(tab .. '}\n') + else + utf8.config.logger(tostring(val)) + end +end + +function utf8.util.debug(...) + local t = {...} + for _, v in ipairs(t) do + if type(v) == "table" and not (getmetatable(v) or {}).__tostring then + dump(v, '\t') + else + utf8.config.logger(tostring(v), " ") + end + end + + utf8.config.logger('\n') +end + +function utf8.debug(...) + if utf8.config.debug then + utf8.config.debug(...) + end +end + +function utf8.util.next(str, bs) + local nbs1 = utf8.next(str, bs) + local nbs2 = utf8.next(str, nbs1) + return utf8.raw.sub(str, nbs1, nbs2 - 1), nbs1 +end + +return utf8.util + +end |
