I am reading the Sparkplug 3.0.0 specification. As far as I can tell, there is absolutely no difference between the String and Text data types, and between Bytes and UInt8Array data types. They hold the same type of data, and are represented the same on the wire (except for the data type field itself). In addition, the specification does not offer any guidance as to why and when can perhaps one be used over the other. Am I missing something? Why is it so?
-
The String data type should be used for human-readable UTF-8 content. The Bytes / Uint8Array data type should be used for binary/non-text content. Text should be ignored unless your specific platform defines it because it is not a standard Sparkplug B type.arpan.r– arpan.r2025-05-26 09:53:13 +00:00Commented May 26 at 9:53
-
This does not help. The first part of your comment describes the difference between strings and texts versus binary data, but that was not my question. I was asking how String differs from Text, and how Bytes differ from UInt8Array. The second part I think is incorrect, because clearly Text is a standard Sparkplug B data type, as described here: sparkplug.eclipse.org/specification/version/3.0/documents/… , pages 76 and 79.ZbynekZ– ZbynekZ2025-05-27 10:13:10 +00:00Commented May 27 at 10:13
1 Answer
You're right to notice that in the Sparkplug 3.0.0 specification, the distinction between some data types, like String vs Text, and Bytes vs UInt8Array. Is not very clear from a technical or implementation standpoint. so here what's the diffrence:
Specification vs. Semantics
Although String and Text (and likewise Bytes and UInt8Array) may appear identical in binary representation and handling, the difference is semantic, not structural. They're intended to carry different contextual meanings.
String vs Text
- Both are UTF-8 encoded text.
Stringis typically used for short identifiers, names, or keys.Textis intended for longer, free-form content like descriptions, messages, or human-readable notes
Bytes vs UInt8Array
- Both hold arbitrary byte arrays.
Bytesis more generic, intended for any binary blob (e.g. images, compressed payloads).UInt8Arraysuggests the content should be interpreted as an array of 8-bit unsigned integers, implying structured binary data (like register values, packed sensor arrays, etc.).
In Simple Terms
if you've ever used HTML, you can think of the differences between Sparkplug's String vs Text, and Bytes vs UInt8Array, as similar to the difference between <div> and semantic HTML tags like <header>, <main>, <footer>, etc.
<div> is just a container, you don’t know what it means unless you dig into its contents or CSS classes. a <footer> explicitly tells you that it’s the bottom section of a page.
Similarly:
Bytes is just raw binary, the meaning must be interpreted externally.
UInt8Array suggests a structured array of numeric values, likely representing sensor data or registers.
SUMMARY: So the distinction is semantic, not technical. It exists to help readers and systems understand the intent behind the data, even though the wire format may be the same