How to publish extended (8bit) ASCII


I need some help publishing 8bit ASCII data.
Here’s what I do:

String Text = "123ÄÖÜäöü123";
Particle.publish("Info",Text, 300, PRIVATE);

Works fine.
Received by webook as

char TEXT[] = {49,50,51,196,214,220,228,246,252,49,50,51,0};
String TextC = String((char*)TEXT);
Particle.publish("Info",TextC, 300, PRIVATE);

Does not work. Received as

Is there a simple way to accomplish this?



Yes there is a way - you need to encode as base64, 3 8bit bytes get converted into 4 6bit characters that can be transferred via the publish as an ascii character 0 to . At the receiving end you need to convert them back. There are libraries to help you do this search for base64 or Base64RK.


The issue here is that you assume the ASCII values for the German Umlaute to map to the same binary values as in the German version of the extended ASCII table.
But as you can see in the working output, they don’t.

These special characters are in fact a combination of two bytes, e.g. Ä maps to 0xC3 0x84 not single byte 0xC4 (196 decimal).


Yes, what ScruffR said. Specifically, the string encoding is UTF-8 (Unicode, 8-bit) not ISO-8859-1 (Latin 1). So characters beyond 7-bit ASCII are represented as two (or more) bytes. All of the high-bit set characters in ISO-8859-1 map to two byte sequences beginning with 0xC2 or 0xC3.

It’s not possible to directly send 8-bit characters or binary data because the data string must be valid UTF-8 sequences, and many sequences of 8-bit bytes are not valid UTF-8.


So I just added a UTF8 conversion and it works.

char TEXT[] = {49,50,51,196,214,220,228,246,252,49,50,51,0};
Particle.publish("Info",ToUTF8(TextC), 300, PRIVATE);

Thanks for the support!


Just a word on your Particle.publish() statement: You have set the TTL to 300 seconds but you are aware that this parameter currently (if ever) doesn’t do anything at all?
There actually is no TTL for Particle events. They are fire and forget and have to be caught there and then.