This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Advertising shortened local name corrupts utf-8 characters

We were playing with renaming some of our test devices to use emoji and other multi-byte utf-8 characters. We have a custom characteristic that allows renaming (since iOS won't allow writes to the device name) and supports up to 31 bytes. This generally works fine, and we've also tested it in the past.

We only have 14 bytes available in our advertising packet for the device name, and we advertise the shortened local name if the custom name is longer than this.

The problem is that the shortened name sometimes splits a multi-byte character in the middle. We've found that Android devices (6 and later) still show the name, with a corrupted character at the end. On recent iOS and OSX versions, though, no name shows up at all. Looks like these systems just drop the name if an invalid string is found.

Is there any SDK support for properly shortening the name to recognize utf-8 character boundaries? I wanted to check before we implement our own solution.

Related