-
-
Notifications
You must be signed in to change notification settings - Fork 9
ubyte
ubyte
represents the type of an unsigned byte value. It can hold values [0, 255]
.
Primitive Type | Bits | Size | Signed-ness | Possible Values | C Equivalent (Roughly) | Suffix |
---|---|---|---|---|---|---|
ubyte |
8 bits | 1 byte | unsigned | 0..255 | unsigned char |
ub |
Character literals are specified by using a single character C-string with the ub
suffix
letter_a ubyte = 'A'ub
Some special characters can be created using escape sequences
'\n' // Newline
'\r' // Carriage Return
'\t' // Tab
'\b' // Backspace
'\e' // ESC
'\0' // Null
'\'' // Apostrophe
'\\' // Backslash
Most commonly, ubyte
is used for null-terminated strings.
planet *ubyte = 'Earth'
Another common usage is for buffers.
array *ubyte = malloc(256)
ubyte
in an unsigned 8-bit integer. It takes up one byte of space (sizeof ubyte == 1
) and can represent values from 0-255. Just like char
in C, it's used as the type to hold an ascii character, but unlike in C, it is guaranteed to be unsigned.
*ubyte
is pointer to a location in memory where one or more ubyte
s are stored.
**ubyte
is pointer to a pointer to a location in memory where one or more ubyte
s are stored.
Here's a graphic, if you have some experience with C then its basically the same as char

Just like in C where []/*
are interchangeable, pointers to values in memory don't indicate how many of what they point to is there. So **ubyte
could be a pointer to a C-String, or it could be a location in memory where several C-Strings are stored.