Module:string/encode entities: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
-- TO BE REPLACED BY encode_entities in [[Module:string utilities]]. This function decodes on input by default to prevent double-encoding, which the new function does not, so implementations need to take this into account when being converted. | -- TO BE REPLACED BY encode_entities in [[Module:string utilities]]. This function decodes on input by default to prevent double-encoding, which the new function does not, so implementations need to take this into account when being converted. | ||
local string_decode_entities_module = "Module:string/decodeEntities" | local string_decode_entities_module = "Module:string/decodeEntities" | ||
local string_utilities_module = "Module:string utilities" | local string_utilities_module = "Module:string utilities" | ||
| Line 15: | Line 14: | ||
encode_entities = require(string_utilities_module).encode_entities | encode_entities = require(string_utilities_module).encode_entities | ||
return encode_entities(...) | return encode_entities(...) | ||
end | end | ||
| Line 25: | Line 19: | ||
if not raw then | if not raw then | ||
local decoded = decode_entities(str) | local decoded = decode_entities(str) | ||
str = decoded | str = decoded | ||
end | end | ||
return encode_entities(str, charset, nil, true) | return encode_entities(str, charset, nil, true) | ||
end | end | ||
Latest revision as of 10:57, 9 May 2026
- This module lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox
-- TO BE REPLACED BY encode_entities in [[Module:string utilities]]. This function decodes on input by default to prevent double-encoding, which the new function does not, so implementations need to take this into account when being converted.
local string_decode_entities_module = "Module:string/decodeEntities"
local string_utilities_module = "Module:string utilities"
local require = require
local function decode_entities(...)
decode_entities = require(string_decode_entities_module)
return decode_entities(...)
end
local function encode_entities(...)
encode_entities = require(string_utilities_module).encode_entities
return encode_entities(...)
end
return function(str, charset, raw)
if not raw then
local decoded = decode_entities(str)
str = decoded
end
return encode_entities(str, charset, nil, true)
end