lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

> but you would be willing to return both the
> charset (name) and decoded text from
> encoded-word = "=?" charset "?" encoding "?" encoded-text "?="
> Well, no, actually it's very nasty as you have to chunk such headers;
> they can even contain multiple different charsets :/
> Hmm, maybe passing an optional recode(charset, bytes) function to be
> called on every such chunk would make for a reasonable interface?

Yes, it is unclear how to do this in a decent way. It might be best to
provide an iterator that returns (charset, decoded text). The user would
be able to do something like this

    local decode = mime.decode("header")
    for charset, value in decode(something) do
        if charset ~= "iso-8859-1" then ignore(value) -- :)
        else use(value) end
    end

Is that good enough?

[]s,
Diego.