-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GDNative] updates to string API and const fixes #15580
Conversation
Note to binding authors: we're likely going to release a RC1 build tomorrow or on Saturday, in case you want to sync your bindings with this breaking change before that. |
@karroffel Given a UTF-8 string, how do you construct
|
godot_string str;
api->godot_string_new(&str);
api->godor_string_parse_utf8(&str, some_text); |
@karroffel got it, thanks! |
So far I don't like this change... makes it far harder to do something that should be simple especially has GDNative will do a lot of interfacing with 3rd party apis which all have simple char buffers for strings and we'll be doing this alot. The parse utf8 works around things, there should be a godot_string_parse_ascii then as well. What I can't see is how to obtain a char * to the data held within a godot string. |
@BastiaanOlij every ASCII text is also valid UTF-8, so there is no need for a To get a char pointer you do this godot_char_string buf = api->godot_string_utf8(&str);
char *t = api->godot_char_string_get_data(&buf);
int len = api->godot_char_string_length(&buf);
// copy the data or use it otherwise
// free the Godot-allocated buffer
api->godot_char_string_destroy(&buf); |
Ah.. by ascii you mean text purely using the first 7 bits? the last 128 characters can't be used directly. but hey, it works.. |
Hopefully the last time I change the API struct before the release.
cc @sheepandshepherd, @endragor, @touilleMan and also @BastiaanOlij, those should be affected by the changes the most.