Skip to content

Latest commit

 

History

History
66 lines (45 loc) · 1.91 KB

README.md

File metadata and controls

66 lines (45 loc) · 1.91 KB

splitsms

Build Status Go Report Card

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.

More info on SMS

go get github.com/foril/splitsms

Example

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)

Output

&{
	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
}

Example - Force UDH length for long message

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}

Example - Force Charset

// Characters Unicode forced in GSM 7
msgInfo := splitsms.Message{FullContent: "🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿🐿", Charset: "GSM"}