Skip to content

cstring null terminated but with a fixed length? #23

@LiamKarlMitchell

Description

@LiamKarlMitchell

How would I make a cstring with a fixed length?

I guess like char name[13]; where the app ensures a length of 12 is always in there or copied from there and last byte is always NULL.

The data i'm reading/writing is fixed

Do I need to add my own custom type for this?
Using count and countType cause validation errors.

Example:

Buffer data
31 33 33 37 00 00 00 00

I would expect to count up to the first NULL terminator.
Reading string as this.
'1337'

But the max length of the cstring would be 7 characters.
With a total byte length of 8.
1 byte at the end for the final NULL terminator if all count-1 characters are set.

31 00 31 00 00 00 00 00
Would be read as a string of '1' the other data is ignored because its null terminated.

I'll code my own for now as I already did wide strings in another project.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions