לדלג לתוכן

יחידה:קידוד ניקוד

מתוך חב"דפדיה, אנציקלופדיה חב"דית חופשית
גרסה מ־15:52, 30 בספטמבר 2025 מאת מ. רובין (שיחה | תרומות) (יצירת דף עם התוכן "-- -- This module implements {{קידוד ניקוד}}. -- local p = {} -- helper functions local function toHex(str) return (str:gsub('.', function (c) return "%" .. string.format('%02X', string.byte(c)) end)) end local function swapHex(str) -- TODO: cleaner code local res = str:gsub("(%%D6%%B0)(%%D6%%BC)","%2%1") res = res:gsub("(%%D6%%B1)(%%D6%%BC)","%2%1") res = res:gsub("(%%D6%%B2)(%%D6%%BC)","%2%1") res = res:gsub("(%%D6%%B3)(%...")
(הבדל) → הגרסה הקודמת | הגרסה האחרונה (הבדל) | הגרסה הבאה ← (הבדל)

ניתן ליצור תיעוד על היחידה הזאת בדף יחידה:קידוד ניקוד/תיעוד

--
-- This module implements {{קידוד ניקוד}}.
--

local p = {}

-- helper functions
local function toHex(str)
    return (str:gsub('.', function (c)
        return "%" .. string.format('%02X', string.byte(c))
    end))
end

local function swapHex(str)
	-- TODO: cleaner code
	local res = str:gsub("(%%D6%%B0)(%%D6%%BC)","%2%1")
	res = res:gsub("(%%D6%%B1)(%%D6%%BC)","%2%1")
	res = res:gsub("(%%D6%%B2)(%%D6%%BC)","%2%1")
	res = res:gsub("(%%D6%%B3)(%%D6%%BC)","%2%1")
	res = res:gsub("(%%D6%%B4)(%%D6%%BC)","%2%1")
	res = res:gsub("(%%D6%%B5)(%%D6%%BC)","%2%1")
	res = res:gsub("(%%D6%%B6)(%%D6%%BC)","%2%1")
	res = res:gsub("(%%D6%%B7)(%%D6%%BC)","%2%1")
	res = res:gsub("(%%D6%%B8)(%%D6%%BC)","%2%1")
	res = res:gsub("(%%D6%%B9)(%%D6%%BC)","%2%1")
	res = res:gsub("(%%D6%%BB)(%%D6%%BC)","%2%1")
	
	res = res:gsub("(%%D6%%B0)(%%D7%%81)","%2%1")
	res = res:gsub("(%%D6%%B1)(%%D7%%81)","%2%1")
	res = res:gsub("(%%D6%%B2)(%%D7%%81)","%2%1")
	res = res:gsub("(%%D6%%B3)(%%D7%%81)","%2%1")
	res = res:gsub("(%%D6%%B4)(%%D7%%81)","%2%1")
	res = res:gsub("(%%D6%%B5)(%%D7%%81)","%2%1")
	res = res:gsub("(%%D6%%B6)(%%D7%%81)","%2%1")
	res = res:gsub("(%%D6%%B7)(%%D7%%81)","%2%1")
	res = res:gsub("(%%D6%%B8)(%%D7%%81)","%2%1")
	res = res:gsub("(%%D6%%B9)(%%D7%%81)","%2%1")
	res = res:gsub("(%%D6%%BB)(%%D7%%81)","%2%1")
	
	res = res:gsub("(%%D6%%B0)(%%D7%%82)","%2%1")
	res = res:gsub("(%%D6%%B1)(%%D7%%82)","%2%1")
	res = res:gsub("(%%D6%%B2)(%%D7%%82)","%2%1")
	res = res:gsub("(%%D6%%B3)(%%D7%%82)","%2%1")
	res = res:gsub("(%%D6%%B4)(%%D7%%82)","%2%1")
	res = res:gsub("(%%D6%%B5)(%%D7%%82)","%2%1")
	res = res:gsub("(%%D6%%B6)(%%D7%%82)","%2%1")
	res = res:gsub("(%%D6%%B7)(%%D7%%82)","%2%1")
	res = res:gsub("(%%D6%%B8)(%%D7%%82)","%2%1")
	res = res:gsub("(%%D6%%B9)(%%D7%%82)","%2%1")
	res = res:gsub("(%%D6%%BB)(%%D7%%82)","%2%1")
	
	return res
end

function p._main(text)
	if text == '' then
        return
	end
	return swapHex(toHex(text))
end

-- main function
function p.main(frame)
    local templateArgs = frame.args
    local text = templateArgs[1] or ''
    return p._main(text)
end

return p