Go library for split SMS.
This library support SMS in GSM 7, basic extended GSM 7 table and Unicode charset.
The size of UDH can be defined for concatened SMS.
go get github.com/foril/splitsms
message := "\n\f\r !\\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_abcdefghijklmnopqrstuvwxyz{|}~¡£¤¥§¿ÄÅÆÇÉÑÖØÜßàäåæèéìñòöøùüΓΔΘΛΞΠΣΦΨΩ€\f[\\]^{|}~€"
msgInfo := splitsms.Message{FullContent: message}
split, err := msgInfo.Split()
if err != nil {
fmt.Println(err)
}
fmt.Println(split)
&{
GSM // Charset detected
154 // Total length of message
180 // Total bytes of message
2 // Number of SMS in message
[ // SMS parts (content of sms, SMS bytes, SMS length )
{\n\f\r !\\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_abcdefghijklmnopqrstuvwxyz{|}~¡£¤¥§¿ÄÅÆÇÉÑÖØÜßàäåæèéìñòöøùüΓΔΘΛΞΠΣΦ 153 139}
{ΨΩ€\f[\\]^{|}~€ 27 15}
]
126 //Characters remaining on last SMS
}
The default length of UDH is (6), SMS parts limited to 153 characters in GSM 7 and 67 characters in Unicode in this case.
For force to UDH length at (7) bytes
// Length of SMS is limited to 152 chars in GSM 7 and 66 characters in Unicode
msgInfo := splitsms.Message{FullContent: "My long message .....", UDH: 7}
// Characters Unicode forced in GSM 7
msgInfo := splitsms.Message{FullContent: "🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿", Charset: "GSM"}