词条 | Module:ISO 8859-1 |
释义 | local p = {} -- Convert pairs of hex digits (optionally separated by-- non-hex-digit characters) in a string to the corresponding bytes.local function from_hex_str(hex_str) return (hex_str:gsub("(%x%x)%X*", function (hex) return string.char(tonumber(hex, 16)) end)) end function p._show_file_signature(str) str = from_hex_str(str):gsub(".", function (char) local byte = char:byte() -- Show C0 and C1 control characters and the delete character as ".". if 0x00 <= byte and byte <= 0x1F or 0x7F <= byte and byte <= 0x9F then return "." -- Between 0xA0 and 0xFF, the byte value is the same as the code -- point for the character that the byte represents in ISO 8859-1. elseif byte >= 0xA0 then return mw.ustring.char(byte) end -- else don't change char end)
return str end function p.show_file_signature(frame) local file_signature = frame:getParent().args[1]
return frame:extensionTag("pre", p._show_file_signature(file_signature)) end return p |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。