From 07d294425a98ee5d1e22d03e2b24ae2c76e487c0 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Sat, 23 Aug 2025 12:42:37 +0900 Subject: updates --- .../mpv/script-modules/utf8/primitives/native.lua | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 mac/.config/mpv/script-modules/utf8/primitives/native.lua (limited to 'mac/.config/mpv/script-modules/utf8/primitives/native.lua') diff --git a/mac/.config/mpv/script-modules/utf8/primitives/native.lua b/mac/.config/mpv/script-modules/utf8/primitives/native.lua new file mode 100644 index 0000000..c9aca54 --- /dev/null +++ b/mac/.config/mpv/script-modules/utf8/primitives/native.lua @@ -0,0 +1,57 @@ +return function(utf8) + +local ffi = require("ffi") +if ffi.os == "Windows" then + os.setlocale(utf8.config.locale or "english_us.65001", "ctype") + ffi.cdef[[ + short towupper(short c); + short towlower(short c); + ]] +else + os.setlocale(utf8.config.locale or "C.UTF-8", "ctype") + ffi.cdef[[ + int towupper(int c); + int towlower(int c); + ]] +end + +utf8:require "primitives.dummy" + +if not utf8.config.conversion.uc_lc then + function utf8.lower(str) + local bs = 1 + local nbs + local bytes = utf8.raw.len(str) + local res = {} + + while bs <= bytes do + nbs = utf8.next(str, bs) + local cp = utf8.unicode(str, bs, nbs) + res[#res + 1] = ffi.C.towlower(cp) + bs = nbs + end + + return utf8.char(utf8.config.unpack(res)) + end +end + +if not utf8.config.conversion.lc_uc then + function utf8.upper(str) + local bs = 1 + local nbs + local bytes = utf8.raw.len(str) + local res = {} + + while bs <= bytes do + nbs = utf8.next(str, bs) + local cp = utf8.unicode(str, bs, nbs) + res[#res + 1] = ffi.C.towupper(cp) + bs = nbs + end + + return utf8.char(utf8.config.unpack(res)) + end +end + +return utf8 +end -- cgit v1.2.3