Skip to content

Encoding for C-struct syntax #22

@vallsv

Description

@vallsv

Sorry to spam, but this makes me think a lot :-)

I have some proposal with the way encoding is handled with the C syntax.

struct person 
{ 
    char name[50];
    char single_char;
};
  • a single char should be decoded like an array. I think it is not the case right now.
  • i think there is no real need to support signed char/unsigned char. As i saw in the documentation Parse source code files, it's probably not a very good C programing style to specify the sign of a char. For that there is the byte type. which is an int8. I think char should only be used for characters.

I also saw that the library uses utf-8 as default. It is probably not a good idea. Such thing could be be latin1, or a lot of other stuffs. It's also possible that encoding stay unknown until the structure is read.

Thinking about that, and following the way packing is handled, maybe this could be generalized for encoding, like using an own pragma.

So what it could be switched in the middle of the description if it is needed.

#pragma encoding("utf-8")
struct person 
{ 
    char name[50];
#pragma encoding("raw")
    char single_char;
};

This said, i don't have such problems for now.
So it's just proposals.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions