jbe@471: --[[-- jbe@471: text = -- a string jbe@471: format.file_path_element( jbe@471: value, -- part of an encoded file path, see encode.file_path_element(...) jbe@471: options -- options as supported by format.string(...) jbe@471: ) jbe@471: jbe@471: Undoes the encoding done by encode.file_path_element(...) and additionally formats the resulting string using the options available for format.string(...). jbe@471: jbe@471: --]]-- jbe@471: jbe@471: function format.file_path_element(value, options) jbe@471: local options = options or {} jbe@471: if value == nil then jbe@471: return options.nil_as or "" jbe@471: else jbe@471: return format.string( jbe@471: string.gsub( jbe@471: tostring(value), jbe@471: "%%(%x%x)", jbe@471: function (hexcode) jbe@471: return string.char(tonumber("0x" .. hexcode)) jbe@471: end jbe@471: ), jbe@471: options jbe@471: ) jbe@471: end jbe@471: end