webmcp
view framework/env/encode/mime/quoted_printable_text_content.lua @ 2:72860d232f32
Version 1.0.2
Fixed bug with explicit garbage collection (requests > 256kB caused an error)
Views prefixed with an underscore can't be called externally
ui.paginate now displays the last page, if the selected page number is too high.
Fixed bug with explicit garbage collection (requests > 256kB caused an error)
Views prefixed with an underscore can't be called externally
ui.paginate now displays the last page, if the selected page number is too high.
| author | jbe/bsw |
|---|---|
| date | Thu Dec 10 12:00:00 2009 +0100 (2009-12-10) |
| parents | 9fdfb27f8e67 |
| children |
line source
1 function encode.mime.quoted_printable_text_content(str)
2 local parts = {}
3 for str_part in string.gmatch(str, "[^\r\n]+[\r\n]*") do
4 local line, extra_gap = string.match(str_part, "^([^\r\n]+)\r?\n?(.*)$")
5 local line_length = 0
6 for char in string.gmatch(line, ".") do
7 if string.find(char, "^[\t -<>-~]$") then
8 if line_length + 1 > 75 then
9 parts[#parts+1] = "=\r\n"
10 line_length = 0
11 end
12 parts[#parts+1] = char
13 line_length = line_length + 1
14 else
15 if line_length + 3 > 75 then
16 parts[#parts+1] = "=\r\n"
17 line_length = 0
18 end
19 parts[#parts+1] = string.format("=%02X", string.byte(char))
20 line_length = line_length + 3
21 end
22 end
23 for i = 1, #extra_gap do
24 if string.sub(extra_gap, i, i) == "\n" then
25 parts[#parts+1] = "\r\n"
26 end
27 end
28 parts[#parts+1] = "\r\n"
29 end
30 return table.concat(parts)
31 end
