UTF-8 / ASCII encoding/decoding [Solved]

Hi there,

Does the Photon support transmission of the 256 different characters in UTF-8 or the 128 characters in ASCII?Iff so, how is it decoded once received?

Thank you.

That depends how you want to transmit.
Binary transport will, … well …, send all bytes as they come, but some functions like Particle.publish() will only be able to send a subset of bytes.

Seems to work for me. Here’s the code I ran:

#include "Particle.h"

int funcTest(String arg);
void subHandler(const char *event, const char *data);

String varTest("jalape\u00F1o 100\u03A9 \u30C4");

void setup() {

	Particle.variable("varTest", varTest);
	Particle.function("funcTest", funcTest);
	Particle.subscribe("testSubReq", subHandler);

	Particle.publish("testPub", varTest, PRIVATE);

void loop() {

int funcTest(String arg) {
	Particle.publish("testFunc", arg, PRIVATE);

	return 0;

void subHandler(const char *event, const char *data) {
	Particle.publish("testSubResp", data, PRIVATE);

Here’s a picture of the Event Log in the console:

I was also able to send and receive UTF-8 characters from the Particle CLI, at least from the Mac Terminal program.

1 Like

Thanks for your response,

I am more in need of a way to transmit information to the Particle P1. We need to transmit 384 bits per transmission, but are limited to 63 characters per transmission. Therefore we would need 7 bits or 128 unique characters. UTF-8 and ASCII are both viable (UTF-8 is preferred), but we weren’t able to transmit data to the Particle with them, as some of the characters did not transmit (the null character and the %). How were you able to get UTF-8 to transmit to Particle?

In other words, is there 128 or 256 unique characters which can be sent to the Particle?

Sending binary is an entirely different problem. You can’t do that. You’ll have to omit some of the low control characters (at least 0x00 and probably some others), and UTF-8 reserves almost all high-bit set codes for 2, 3, and 4 byte Unicode sequences. The only safe transport for binary data is somewhere around ASCII-85 encoding (4 8-bit bytes in 5 characters).


Thank you! Base85 / ASCII85 works.

1 Like

Thanks @ScruffR @rickkas7 for helping out!