Module:DecodeEncode

local p = {}

function _getBoolean( boolean_str ) -- from: module:String; adapted -- requires an explicit true local boolean_value

if type( boolean_str ) == 'string' then boolean_str = boolean_str:lower if boolean_str == 'true' or boolean_str == 'yes' or boolean_str == '1' then boolean_value = true else boolean_value = false end elseif type( boolean_str ) == 'boolean' then boolean_value = boolean_str else boolean_value = false end return boolean_value end

function p.decode( frame ) local s	local XMLonly

s = frame.args['s'] or '' XMLonly = _getBoolean(frame.args['XMLonly'] or false)

return p._decode( s, XMLonly ) end

function p._decode( s, XMLonly ) local ret = nil;

local stext = 'unk' if XMLonly==nil then stext='nil' elseif XMLonly==false then stext='F' else stext='T' end

ret = mw.text.decode( s, not XMLonly ) .. ' (dbg: s: ' .. s .. ' XMLonly: ' .. stext ..')'

return ret end

function p.encode( frame ) local s local charset

s = frame.args['s'] or '' charset = _getBoolean(frame.args['charset'] or 'nl')

return p._encode( s, charset ) end

function p._encode( s, charset ) local ret = 'textEncode-todo'

ret = mw.text.encode( s, charset ) .. ' (dbg: s: ' .. s .. ' charset: ' .. charset ..')'

return ret end

return p