m4hi2

m4hi2

Sms_part_counter - Counts the character usage of a SMS using GSM7Bit/UCS-2 encoding charset

Released my first Elixir Package a few days ago. I wrote it last year while creating an SMS aggregation platform with Elixir. Since we had to charge our clients based on the number of SMSes they sent, we needed to count the SMS. Now it’s a bit tricky because you might have already noticed that for longer SMSes, you don’t get charged for one SMS but for multiple. The reason is that while sending the long SMS is divided into parts and you’re billed for each part you send. The division is done because the network can work with 1120 bits of data at a time (early implementation limitations, GSM is old).

Now you might think, we can roughly fit ~140 chars in 1120 bits, just count the chars and we’ll have the part count. Well, that is not entirely true because of encoding. We can fit 153 chars of ISO 8859-1 or ISO 8859-15 encoding but only 70 chars for UTF-8. Also, the total maximum length of an SMS changes from 459 to 201. Checking for the max length was out of scope for this package. So the detection of encoding was done. This might sound complicated but it was a fairly simple thing.

I’d like to know the thoughts of the experienced devs on this forum. I know it’s a very niche use case and lib, but the code is very simple and short :slight_smile: Thanks!

Links:

Where Next?

Popular in Announcing Top

mischov
import Meeseeks.CSS html = HTTPoison.get!("https://news.ycombinator.com/").body for story <- Meeseeks.all(html, css("tr.athing")) do...
New
Crowdhailer
I have been updating a library that allows you to pipe between functions that use the erlang result tuple convention. Assuming you have ...
New
mikehostetler
I’m excited to announce Jido, a framework providing foundational primitives for building autonomous agent systems in Elixir. While develo...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
RobertDober
Earmark is a pure-Elixir Markdown converter. It is intended to be used as a library (just call Earmark.as_html), but can also be used as...
239 12673 134
New
sbs
Only 650 LOC, wrote for fun :slight_smile: https://github.com/sunboshan/qrcode
New
versilov
Could not wait for the missing Elixir ML libraries to appear, so, I wrote one myself, taking https://github.com/sdwolfz/exlearn as a foun...
New
achempion
Hi, I would like to tell about my initiative to further maintain and develop Waffle project which is the fork of Arc library. The progre...
New
archan937
It is a well-know topic within the Elixir community: “To mock or not to mock? :)” Every alchemist probably has his / her own opinion con...
New

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New

We're in Beta

About us Mission Statement