Skip to content

Clarify encoding used for C strings in the API. #355

@markshannon

Description

@markshannon

It is not clear what encoding is used for C strings in the API. Are they ASCII, latin-1, or utf-8?

Either make this clear in the docs (maybe it is, but my cursory inspection didn't find it), or better still in the API itself.
A simple typedef would suffice.

typedef const char *Utf8String;

This would also make it clearer what is text data, and what is just bytes.

In HPyBytes_FromStringAndSize(HPyContext *ctx, const char *v, HPy_ssize_t len), v is just an array of bytes,
but in HPyImport_ImportModule(HPyContext *ctx, const char *name) name is a name.
The name gives a clue, but the encoding is hidden.
HPyImport_ImportModule(HPyContext *ctx, Utf8String name) is much clearer.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions