Skip to content

A set of Java™ Charset implementations supporting various codecs used in telecommunications (GSM/UCS2)

License

Notifications You must be signed in to change notification settings

brake/telecom-charsets

Repository files navigation

telecom-charsets

License: MIT GitHub version Maven Central Java version 1.7+ Build Status Maintainability codecov

A set of Java™ Charset implementations supporting various codecs used in telecommunications (GSM/UCS2)

Changelog

Table of Contents

Purpose

There are several implementations of telecom text encoders and decoders over Internet. What I don't like is that you have to copy/past (or reinvent) some code into a static method of some additional utility class inside of application. Over and over, for each application. Problem I'm trying to solve is to give ability for developers of using convinient, Java™ idiomatic way to encode and decode between text and bytes. Idiomatic way IMHO is Charset implementation.

Supported Character Sets

Class Name Description Canonical Name Aliases Encoding Support Decoding Support
GSMCharset GSM 7 Bit Encoding described in ETSI TS 123 038 (6.2.1, 6.2.1.1). Note that there is no support of National Language Tables (6.2.1.2, Annex A). X-GSM7BIT GSM, GSM7BIT #c5f015 Yes #c5f015 Yes
GSM7BitPackedCharset GSM 7 Bit Packed based on GSM 7 bit charset with base packing as described in ETSI TS 123 038 (6.1.2.1 SMS Packing) X-GSM7BIT-PACKED GSM-PACKED, GSM-7BIT-PACKED, GSM7BP #c5f015 Yes #c5f015 Yes
UCS2Charset80 UCS2 with tag 0x80 (AKA 80th encoding) implementation based on ETSI TS 102 221 (Annex A, part 1) X-UCS2-80 UCS2-80, UCS2x80 #c5f015 Yes #c5f015 Yes
UCS2Charset81 UCS2 with tag 0x81 (AKA 81th encoding) implementation based on ETSI TS 102 221 (Annex A, part 2) X-UCS2-81 UCS2-81, UCS2x81 #c5f015 Yes #c5f015 Yes
TelecomCharset Charset implementation which is able to decode bytes in one of following encodings: GSM 7 Bit, UCS2 with tags 0x80 and 0x81 X-GSM-UCS2 ANY-TELECOM, TELECOM, GSM-OR-UCS2 #f03c15 No #c5f015 Yes

Requirements

Java 1.7 or higher.

Download

Direct link to Maven Central for case if we decide to use library as described in Usage, part 1.

Dependency Configuration

Gradle:

compile 'com.github.brake.threegpp:telecom-charsets:1.0.1'

Maven:

<dependency>
  <groupId>com.github.brake.threegpp</groupId>
  <artifactId>telecom-charsets</artifactId>
  <version>1.0.1</version>
</dependency>

Usage

There are two ways to use this library (see Note1).

  1. Download a precompiled jar file and place it to extension directory of your JRE.

    After that you, without further configuration, can just write and run code like this:

    import java.nio.charset.Charset;
    
    Charset UCS2x80 = Charset.forName("UCS2x80");
    byte [] telecomText = "My Menu Item Name".getBytes(UCS2x80);

    More information about JRE Extension Path on your system you can get from links below:

  2. Configure a dependency in your project as you are usually doing for external libraries (Gradle or Maven)

    import threegpp.charset.ucs2.UCS2Charset80;
    
    Charset cs80 = new UCS2Charset80();
    byte [] telecomText = "Some Text".getBytes(cs80);

Note1

As mentioned here "Some string".getBytes(someCharset) don't produce exceptions in case of someCharset is unable to encode given string. In order to take more control over encoding process consider to use class CharsetEncoder via someCharset.newEncoder().

Licence

Copyright © 2017-2018 Constantin Roganov

Distributed under the MIT License.

Related links

About

A set of Java™ Charset implementations supporting various codecs used in telecommunications (GSM/UCS2)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages