# System.serial special characters GSM-7 encoding

**URL:** <https://forum.inductiveautomation.com/t/system-serial-special-characters-gsm-7-encoding/62547>\
**Category:** Ignition\
**Tags:** ignition81, scripting, perspective\
**Created:** [August 1, 2022, 2:03pm UTC](https://forum.inductiveautomation.com/t/system-serial-special-characters-gsm-7-encoding/62547 "2022-08-01T14:03:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tupanaster](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@tupanaster](https://forum.inductiveautomation.com/u/tupanaster)\
**Post date:** [August 1, 2022, 2:03pm UTC](https://forum.inductiveautomation.com/t/system-serial-special-characters-gsm-7-encoding/62547/1 "2022-08-01T14:03:19Z")

</div>

Hi everyone,

Is it possible to send special characters using [system.serial.writeBytes](https://docs.inductiveautomation.com/display/DOC81/system.serial.writeBytes) or [system.serial.write](https://docs.inductiveautomation.com/display/DOC81/system.serial.write)? (GSM-7 encoding)

Some resources:  
[Danish letters in AT command](https://stackoverflow.com/questions/65598708/danish-letters-in-at-command)  
[String to bytes in both Python 2 and 3](https://stackoverflow.com/questions/29751751/string-to-bytes-in-both-python-2-and-3)  
[Python library for converting plain text (ASCII) into GSM 7-bit character set?](https://stackoverflow.com/questions/2452861/python-library-for-converting-plain-text-ascii-into-gsm-7-bit-character-set)  
[Convert string to list of bits and viceversa](https://stackoverflow.com/questions/10237926/convert-string-to-list-of-bits-and-viceversa)

Although I can get a chain of 7-bit characters like `48656c6c6f20576f726c64` I’m unable to write that exact character chain using `system.serial` functions.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 1, 2022, 3:50pm UTC](https://forum.inductiveautomation.com/t/system-serial-special-characters-gsm-7-encoding/62547/2 "2022-08-01T15:50:22Z")

</div>

You need to get the bytes into a java array of bytes. Python 2 type are inadequate. Jython’s [jarray module](https://www.jython.org/jython-old-sites/archive/21/docs/jarray.html) is what you need, paired with system.serial.writeBytes.

---

<div class="post-metadata">

**Author:** ![tupanaster](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@tupanaster](https://forum.inductiveautomation.com/u/tupanaster)\
**Post date:** [August 1, 2022, 6:35pm UTC](https://forum.inductiveautomation.com/t/system-serial-special-characters-gsm-7-encoding/62547/3 "2022-08-01T18:35:46Z")

</div>

Ok, that’s something I wouldn’t have thought about.

After having a look at it, I think it should be: string → 7-bit GSM → toBit → jarray module.

I’ll try it out tomorrow. Thanks again @pturmel

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 1, 2022, 8:17pm UTC](https://forum.inductiveautomation.com/t/system-serial-special-characters-gsm-7-encoding/62547/4 "2022-08-01T20:17:06Z")

</div>

If you include a GSM-7 charset provider (an exercise for the reader; there’s an open-source implementation here: [GitHub - OpenSmpp/opensmpp: OpenSmpp - Java library implementing the SMPP protocol, and allowing development of External Short Message Entities (ESMEs) and more.](https://github.com/OpenSmpp/opensmpp)) you could create a Java `String` instance from a Jython string and just call `someString.getBytes("GSM-7")`. Manually encoding to/from GSM-7 will be tricky.

---

<div class="post-metadata">

**Author:** ![tupanaster](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@tupanaster](https://forum.inductiveautomation.com/u/tupanaster)\
**Post date:** [August 2, 2022, 12:23pm UTC](https://forum.inductiveautomation.com/t/system-serial-special-characters-gsm-7-encoding/62547/5 "2022-08-02T12:23:10Z")

</div>

After some testing today I used:

```auto
bitList = [0,0,0,0,0,0,1,0]
jarrayBit = array(bitList, 'b')

```

with `system.serial.write()`. Both gave me the same results with the device I'm using; which was nothing 😆 but I learned a few things along the line and I used system.serial.write() with ISO-8859-1.

> [@paul-griffith](#):
>
> Manually encoding to/from GSM-7 will be tricky.

It is tricky. I had a dive in it today reaching to sites like this: [DoubleBlak](https://doubleblak.com/blogPosts.php?id=6)

Btw, there is a typo in the manual for ISO-8859-1. It has a zero instead of an "O"

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [August 2, 2022, 5:24pm UTC](https://forum.inductiveautomation.com/t/system-serial-special-characters-gsm-7-encoding/62547/6 "2022-08-02T17:24:48Z")

</div>

> [@tupanaster](#):
>
> there is a typo in the manual for ISO-8859-1. It has a zero instead of an “O”

Not anymore there isn't. 😉
