TwilioDevEd / message-segment-calculator

JS-based tool to calculate and display message segmentation data for a given message body
https://twiliodeved.github.io/message-segment-calculator/
MIT License
85 stars 35 forks source link

Incorrect segment counting #39

Open kasyrm opened 1 year ago

kasyrm commented 1 year ago

I spotted a similar issue to this one: https://github.com/TwilioDevEd/message-segment-calculator/issues/18.

When providing a message like this one: ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

Segment calculator shows it's 3 segments.

It's 153 scalars counted as 306 characters. That's 2142 bits for characters + 96 bits for 2 headers. That should add up to 2238 bits so still within 2 segments.

But when adding the last character of this string another header is added and the message takes up 2286 bits: 3 segments.

There are other calculators that show this as 2 segments (https://sakari.io/sms-length-calculator/)

But when sending the message on Twillio it is sent as 3 segments. So I have been wondering which is correct and what is causing this behaviour.

jarangutan commented 5 months ago

I don't believe that the segment calculator is incorrect. For GSM-7 encoding, ] is hex 1B3E which is reflected accurately as 0x001B 0x003E. Right square bracket is one of the extra characters in the extension table that use the escape character 0x001B. That escape character makes right square bracket into two characters rather than one, which eats into the message character limit. See here https://www.developershome.com/sms/gsmAlphabet.asp

Paraphrasing a bit:

GSM 7-bit default alphabet consists of 128 characters with each character being represented by 7 bits. 10 extra characters are defined in an extension table and are represented through an escape mechanism using the escape character 0x1B. The 10 extra characters are:

  • Form feed
  • Caret / circumflex
  • Left curly bracket
  • Right curly bracket
  • Backslash
  • Left square bracket
  • Tilde
  • Right square bracket
  • Vertical bar
  • Euro sign
amanovofficial commented 5 months ago

]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

Checked out this string using https://messente.com/documentation/tools/sms-length-calculator it shows that the string splits into 2 segments but your calculator considers it as 3 segments.

StandBackBurrito commented 1 week ago

]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

Checked out this string using https://messente.com/documentation/tools/sms-length-calculator it shows that the string splits into 2 segments but your calculator considers it as 3 segments.

This site says 2 parts, but it has 3 headers with a single ] after the last header.

image