Do the Allegro 5 config file routines support UTF-8?
You can do this:
al_set_config_value(cfg, "foo", "bar", al_cstr(str));
See al_cstr for a list of warnings. (al_ustr_to_buffer or al_cstr_dup could be used to avoid those problems.)
Thanks. Apparently allegro config files can contain UTF-8, and therefore they are also useful as translation files.
From an end-user perspective, the only thing that is relevant is that they are saving the file with UTF-8 encoding. Then you'll get the support "for free."
e.g.,
int main() { const char euro[] = {0xe2, 0x82, 0xac, 0}; ALLEGRO_USTR *str; al_init(); str = al_ustr_new(euro); printf("%d\n", al_ustr_length(str)); return 0; }
reports 1 as the length of the string, as it should. It doesn't matter if the source comes from a hard coded string or the result of a config file read.