0 $ç-- -- This is file `pdftexcmds.lua', -- generated with the docstrip utility. -- -- The original source files were: -- -- pdftexcmds.dtx (with options: `lua') -- -- This is a generated file. -- -- Project: pdftexcmds -- Version: 2020-06-27 v0.33 -- -- Copyright (C) -- 2007, 2009-2011 Heiko Oberdiek -- 2016-2019 Oberdiek Package Support Group -- -- This work may be distributed and/or modified under the -- conditions of the LaTeX Project Public License, either -- version 1.3c of this license or (at your option) any later -- version. This version of this license is in -- https://www.latex-project.org/lppl/lppl-1-3c.txt -- and the latest version of this license is in -- https://www.latex-project.org/lppl.txt -- and version 1.3 or later is part of all distributions of -- LaTeX version 2005/12/01 or later. -- -- This work has the LPPL maintenance status "maintained". -- -- The Current Maintainers of this work are -- Heiko Oberdiek and the Oberdiek Package Support Group -- https://github.com/ho-tex/pdftexcmds/issues -- -- The Base Interpreter refers to any `TeX-Format', -- because some files are installed in TDS:tex/generic//. -- -- This work consists of the main source file pdftexcmds.dtx -- and the derived files -- pdftexcmds.sty, pdftexcmds.pdf, pdftexcmds.ins, pdftexcmds.drv, -- pdftexcmds.lua. -- oberdiek = oberdiek or {} local pdftexcmds = oberdiek.pdftexcmds or {} oberdiek.pdftexcmds = pdftexcmds local systemexitstatus function pdftexcmds.getversion() tex.write("2020-06-27 v0.33") end function pdftexcmds.strcmp(A, B) if A == B then tex.write("0") elseif A < B then tex.write("-1") else tex.write("1") end end local function utf8_to_byte(str) local i = 0 local n = string.len(str) local t = {} while i < n do i = i + 1 local a = string.byte(str, i) if a < 128 then table.insert(t, string.char(a)) else if a >= 192 and i < n then i = i + 1 local b = string.byte(str, i) if b < 128 or b >= 192 then i = i - 1 elseif a == 194 then table.insert(t, string.char(b)) elseif a == 195 then table.insert(t, string.char(b + 64)) end end end end return table.concat(t) end function pdftexcmds.escapehex(str, mode) if mode == "byte" then str = utf8_to_byte(str) end tex.write((string.gsub(str, ".", function (ch) return string.format("%02X", string.byte(ch)) end ))) end function pdftexcmds.unescapehex(str, mode, patch) local a = 0 local first = true local result = {} for i = 1, string.len(str), 1 do local ch = string.byte(str, i) if ch >= 48 and ch <= 57 then ch = ch - 48 elseif ch >= 65 and ch <= 70 then ch = ch - 55 elseif ch >= 97 and ch <= 102 then ch = ch - 87 else ch = nil end if ch then if first then a = ch * 16 first = false else table.insert(result, a + ch) first = true end end end if not first then table.insert(result, a) end if patch == 1 then local temp = {} for i, a in ipairs(result) do if a == 0 then table.insert(temp, 1) table.insert(temp, 1) else if a == 1 then table.insert(temp, 1) table.insert(temp, 2) else table.insert(temp, a) end end end result = temp end if mode == "byte" then local utf8 = {} for i, a in ipairs(result) do if a < 128 then table.insert(utf8, a) else if a < 192 then table.insert(utf8, 194) a = a - 128 else table.insert(utf8, 195) a = a - 192 end table.insert(utf8, a + 128) end end result = utf8 end local unpack = _G["unpack"] or table.unpack tex.settoks(pdftexcmds.toks, string.char(unpack(result))) end function pdftexcmds.escapestring(str, mode) if mode == "byte" then str = utf8_to_byte(str) end te