al_cstr
const char *al_cstr(const ALLEGRO_USTR *us)
Introduced in 5.0.0
Get a char *
pointer to the data in a string. This pointer will only be valid while the underlying string is not modified and not destroyed. The pointer may be passed to functions expecting C-style strings, with the following caveats:
ALLEGRO_USTRs are allowed to contain embedded NUL ('\0') bytes. That means
al_ustr_size(u)
andstrlen(al_cstr(u))
may not agree.An ALLEGRO_USTR may be created in such a way that it is not NUL terminated. A string which is dynamically allocated will always be NUL terminated, but a string which references the middle of another string or region of memory will not be NUL terminated.
If the ALLEGRO_USTR references another string, the returned c-string will point into the referenced string, the length of the string will be ignored.
See also: al_ustr_to_buffer, al_cstr_dup
Most helpful discussions:
- [A5] Writing Unicode to a file (1)
- al_load_bitmap question
- al_ref_ustr start and end effect
- Input routine works, then does not
- Question about ALLEGRO_EVENT_KEY_CHAR
- open directories with special characters
- Text input using allegro 5
- Weird Crash
- al_fprintf
- Native file dialog patch
Other recent discussions:
- how to use fprintf in ALLEGRO_FILE?
- File I/O
- [A5] al_save_bitmap can't pass a variable for the filename?
- Converting allegro_key_xxx to the same character
- Images from buffer
- Internationalization
- Differences betwen al_ustr_new and al_ustr_new()
- Object Serialization C++
- [a5] keyboard.unichar help needed
- Writing/Reading UTF-8 files in C++