This section describes the details for sting handling.
All character strings used in the API are required to be UTF-8 encoded. These include:
- client id
- topic names
UTF-8 is a variable length encoding for unicode characters but is backward compatible with ASCII, which means that ASCII characters need no special preparation. If a string that does not conform to UTF-8 is used, an error is returned from the function call.
Null-terminated character strings
To make it easy for C programs to use this API, all input character strings must be null-terminated, which means that nulls cannot be part of the string itself. The topic name returned by the messageArrived
callback or receive
call also has this feature. If a message is received with a topic name that contains a null character, then that fact is indicated by the topic name length parameter being non-zero. The full topic name can be retrieved by using this length;a value of zero indicates that the string is a normal, null-terminated string.
Parent topic: Using the MQTT C Client