Download the PHP package benmorel/gsm-charset-converter without Composer

On this page you can find all versions of the php package benmorel/gsm-charset-converter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package gsm-charset-converter

GSM Charset Converter

A PHP library to convert GSM 03.38, the charset used for SMS messaging, to and from UTF-8.

Build Status Coverage Status Latest Stable Version Total Downloads License

This library is well tested. The character maps used have been cross-checked against multiple sources, and when in doubt, a test has been performed on a real SMS gateway.

The library offers optional transliteration: unsupported characters can be replaced with a close variant. For example, the ë character can be replaced with e.

Known limitations:

Installation

This library is installable via Composer:

Requirements

This library requires PHP >= 7.4, and the mbstring extension.

Project status & release process

This library is under development.

The current releases are numbered 0.x.y. When a non-breaking change is introduced (adding new methods, optimizing existing code, etc.), y is incremented.

When a breaking change is introduced, a new 0.x version cycle is always started.

It is therefore safe to lock your project to a given release cycle, such as 0.3.*.

If you need to upgrade to a newer release cycle, check the release history for a list of changes introduced by each further 0.x.0 version.

Usage

Converting GSM 03.38 strings to UTF-8

The convertGsmToUtf8() method takes one parameter:

The input string must be a valid GSM 03.38 string, or an InvalidArgumentException is thrown. The input string is expected to be unpacked: 7-bit chars in 8-bit bytes with a leading zero bit, just like ASCII chars.

Converting UTF-8 strings to GSM 03.38

The convertUtf8ToGsm() method accepts 3 parameters:

If the input string is not valid UTF-8, an InvalidArgumentException is thrown.

The output is an unpacked GSM 03.38 string.

Without transliteration

If the third parameter is not provided, and the string contains characters incompatible with GSM 03.38, an InvalidArgumentException is thrown.

With transliteration

If the third parameter is not provided, and the string contains characters incompatible with GSM 03.38 and not transliterable, an InvalidArgumentException is thrown.

Cleaning up UTF-8 strings to ensure that a message is sent in the GSM charset

Nowadays, most online SMS gateways accept UTF-8 as input; however, some of them do not provide a way to force a message to be sent in the GSM charset.

As a result, you may end up with extra charges caused by your SMS being sent in Unicode (UCS-2) format, causing the segmentation of messages in multiple parts, just because your SMS message contains an unforeseen accented character or emoji.

The library provides a method, cleanUpUtf8String(), that prevents these bad surprises, by returning a UTF-8 string that contains only characters that can be safely converted to the GSM charset.

This method accepts the same parameters as convertUtf8ToGsm():

Packing 7-bit strings into 8-bit binary strings

To fit 160 7-bit characters into a 140 bytes SMS, the characters have to be packed into a binary, 8-bit string. The Packer class provides functionality to pack and unpack strings in this format:

Note that pack() throws an InvalidArgumentException if the input string contains 8-bit chars (i.e. chars with the leading bit set).


All versions of gsm-charset-converter with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package benmorel/gsm-charset-converter contains the following files

Loading the files please wait ....