OpenCyphal / specification

The Cyphal specification documents are maintained here.
https://opencyphal.org/specification
Creative Commons Attribution 4.0 International
41 stars 13 forks source link

DSDL string type #51

Open pavel-kirienko opened 5 years ago

pavel-kirienko commented 5 years ago

We will need native support for strings in UAVCAN v1.1 or later to avoid ambiguity like:

uint8[<=100] text
pavel-kirienko commented 5 years ago

I propose a specialization of uint8 for strings named utf8. While equivalent to uint8 serialization-wise, the new type hints code generators that the field in question is not an array of numbers but rather is a UTF-8 encoded text string. A similar approach is used in RTCM 3.

Likewise, a new scalar alias byte should be defined to indicate that the field is neither a text string nor an array of integers, but an unstructured sequence of octets.

When used as a scalar, utf8 and byte may be transformed into appropriate constructs according to the capabilities of the target programming language, e.g., utf8 as char in C.

uint8[<=100] numbers
utf8[<=100]  text
byte[<=100]  binary_image

uint8 number
utf8  character
byte  one_byte_long_image