summaryrefslogtreecommitdiff
path: root/ar/.config/mpv/script-modules/utf8/util.lua
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-01-24 20:35:27 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-01-24 20:35:27 +0900
commitc80a54e42b52ce297f0f2f71af23c562832025c7 (patch)
treedcce8bb977a770f473325d48f6f70b21d9818a40 /ar/.config/mpv/script-modules/utf8/util.lua
init
Diffstat (limited to 'ar/.config/mpv/script-modules/utf8/util.lua')
-rw-r--r--ar/.config/mpv/script-modules/utf8/util.lua64
1 files changed, 64 insertions, 0 deletions
diff --git a/ar/.config/mpv/script-modules/utf8/util.lua b/ar/.config/mpv/script-modules/utf8/util.lua
new file mode 100644
index 0000000..7723626
--- /dev/null
+++ b/ar/.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