telecom-charsets
A set of Java™ Charset implementations supporting various codecs used in telecommunications (GSM/UCS2)
Table of Contents
- Purpose
- Supported Character Sets
- Requirements
- Download
- Dependency Configuration
- Usage
- License
- Related links
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
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).
-
Download a precompiled
jar
file and place it to extension directory of yourJRE
.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:
-
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
- Some charset encoding/decoding related code
- From code.google.com, GSM
- Useful SO answer regarding UCS2 (80th)
- AOSP