splitsms

package module
v0.0.0-...-a183003 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2017 License: MIT Imports: 2 Imported by: 0

README

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"}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsGSM7

func IsGSM7(msg string) bool

IsGSM7 - Test if message is GSM 7 charset

func IsUnicode

func IsUnicode(msg string) bool

IsUnicode - Test if message is Unicode charset

Types

type Message

type Message struct {
	FullContent string
	Charset     string
	UDH         int
}

Message - message to split

func (*Message) Split

func (m *Message) Split() (*Split, error)

type Sms

type Sms struct {
	Content string
	Bytes   int
	Length  int
}

SMS - Parts contains in my message

type Split

type Split struct {
	Charset        string // GSM or Unicode
	Length         int    // Total length of message
	Bytes          int    // Total bytes of message
	CountParts     int    // Number of SMS in message
	Parts          []Sms  // SMS parts
	RemainingChars int    // Remaining char in current SMS
}

Split - result of message splitted

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL