namespace SmsSluzba.Api.Messages; internal static class SmsText { // The gateway truncates longer texts: at most 3 concatenated parts of 153 GSM characters. public const int MaxLength = 459; // GSM 03.38 extension table: each of these is sent as escape + character, so it takes two positions. private const string GsmExtensionCharacters = "€[]{}\\^~|"; public static int CountLength(string text) { var length = 0; foreach (var rune in text.EnumerateRunes()) { length += rune.IsBmp && GsmExtensionCharacters.Contains((char)rune.Value, StringComparison.Ordinal) ? 2 : 1; } return length; } }