This repo contains a package for an SMS segments calculator. The package is released as nodeJS package as well as browser script. A browser demo for this package can be accessed here
Sample usage:
const { SegmentedMessage } = require('sms-segment-calculator');
const segmentedMessage = new SegmentedMessage('Hello World');
console.log(segmentedMessage.encodingName); // "GSM-7"
console.log(segmentedMessage.segments.length); // "2"
You can add the library to your page using:
<script type="text/javascript" src="scripts/segmentsCalculator.js"></script>
This is the main class exposed by the package
Arguments:
message
: Body of the SMSencoding
: Optional: encoding. It can beGSM-7
,UCS-2
,auto
. Default value:auto
Returns the name of the calculated encoding for the message: GSM-7
or UCS-2
Total size of the message in bits (including User Data Header if present)
Total size of the message in bits (excluding User Data Header if present)
Number of segment(s)
This template is open source and welcomes contributions. All contributions are subject to our Code of Conduct.
No warranty expressed or implied. Software is as is.