encode_mail.anubis
1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* Created by PyramIDE.
* User: フランスのトトロ aka (David RENÉ)
* Date: 12/07/2017
* Time: 22:02
* © David RENÉ
*/
read tools/base64.anubis
read tools/basis.anubis
read system/string.anubis
public define String
to_folded_base64_text
(
String charset,
String text,
) =
with l = length(text),
max_length = (Int)48,
if l > max_length then
if sub_string(text, 0, max_length) is
{
failure then "", // can't occures
success(left_text) then
with text2 = "=?"+charset+"?B?"+to_string(base64_encode(to_byte_array(left_text)))+"?=",
if sub_string(text, max_length, l - max_length) is
{
failure then "", // can't occures
success(rigth_text) then
text2 + crlf + " " + to_folded_base64_text(charset, rigth_text)
}
}
else if l > 0 then
"=?"+charset+"?B?"+to_string(base64_encode(to_byte_array(text)))+"?="
//find_and_replace(text2, implode([13,10]), implode([13,10,32]))
else
"".