Re: [Vala] Help with manual binding vapi for old C lib that uses only ASCII.



   > On Saturday, 11 January 2020, 01:59:00 GMT, Jason Martin via vala-list <vala-list gnome org> wrote:  
Does [CCode (type = "char*")] limit string to ascii only?

char declares the type so the compiler knows the size of the memory. On POSIX (Unix) and most other platforms 
that is 8 bits. The * indicates the parameter is a pointer to that data type. The rest is convention. So 
typically char* points to an array of char that is used to hold a string. The convention in C is for this 
array to be terminated by zero. The character encoding is not specified to the compiler, it is a matter to be 
agreed upon by the programs using the char array. It could be ASCII, but there are plenty of other character 
encodings that can fit in a char (typically 8 bits) and this include multi-byte encodings like Unicode's 
UTF-8. So, no, [CCode (type = "char*")] doesn't limit the string to ASCII.

If not should I just use char*?Good question. You should probably just use 'string' to start with. I guess 
the [CCode (type = "char*")] is to stop a compiler warning about gchar*, but I've not investigate that with 
any code.
Hope that helps,
Al
  


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]