localgsub=string.gsublocalmatch=string.matchlocaltonumber=tonumberlocalulocalentitieslocalfunctiondecode_numeric_entity(code,pattern,base)u=uorrequire("Module:string/char")localcp=match(code,pattern)andtonumber(code,base)returncpandcp<0x110000andu(cp)ornilendlocalfunctiondecode_entity(hash,x,code)ifhash=="#"thenreturnx==""anddecode_numeric_entity(code,"^%d+$")ordecode_numeric_entity(code,"^%x+$",16)endentities=entitiesormw.loadData("Module:data/entities")returnentities[x..code]end-- Non-ASCII characters aren't valid in proper HTML named entities, but MediaWiki uses them in some custom aliases which are also included in [[Module:data/entities]].returnfunction(this)return(gsub(this,"&(#?)([Xx]?)([%w\128-\255]+);",decode_entity))end