Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send mails that correspond to RFC2045 with a base64 line limit of 76 …
…characters.
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package notifications | ||
|
||
import "bytes" | ||
|
||
// SplitSubN splits a string into a list of string with each having | ||
// a maximum number of characters n | ||
func SplitSubN(s string, n int) []string { | ||
sub := "" | ||
subs := []string{} | ||
|
||
runes := bytes.Runes([]byte(s)) | ||
l := len(runes) | ||
for i, r := range runes { | ||
sub = sub + string(r) | ||
if (i+1)%n == 0 { | ||
subs = append(subs, sub) | ||
sub = "" | ||
} else if (i + 1) == l { | ||
subs = append(subs, sub) | ||
} | ||
} | ||
|
||
return subs | ||
} |