From 69511102de9b0f3ec6ad555baf2a01d9ee1c3dfd Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Sat, 13 Jun 2009 08:22:37 +0000 Subject: improved the font system even futher. utf8 is now used everywhere. it uses less memory as well --- src/base/system.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'src/base/system.h') diff --git a/src/base/system.h b/src/base/system.h index 3aa01cab..87cae4a0 100644 --- a/src/base/system.h +++ b/src/base/system.h @@ -947,6 +947,69 @@ int str_isspace(char c); */ void gui_messagebox(const char *title, const char *message); + +/* + Function: str_utf8_rewind + Moves a cursor backwards in an utf8 string + + Parameters: + str - utf8 string + cursor - position in the string + + Returns: + New cursor position. + + Remarks: + - Won't move the cursor less then 0 +*/ +int str_utf8_rewind(const char *str, int cursor); + +/* + Function: str_utf8_forward + Moves a cursor forwards in an utf8 string + + Parameters: + str - utf8 string + cursor - position in the string + + Returns: + New cursor position. + + Remarks: + - Won't move the cursor beyond the zero termination marker +*/ +int str_utf8_forward(const char *str, int cursor); + +/* + Function: str_utf8_decode + Decodes an utf8 character + + Parameters: + ptr - pointer to an utf8 string. this pointer will be moved forward + + Returns: + Unicode value for the character. -1 for invalid characters and 0 for end of string. + + Remarks: + - This function will also move the pointer forward. +*/ +int str_utf8_decode(const char **ptr); + +/* + Function: str_utf8_encode + Encode an utf8 character + + Parameters: + ptr - Pointer to a buffer that should recive the data. Should be able to hold at least 4 bytes. + + Returns: + Number of bytes put into the buffer. + + Remarks: + - Does not do zero termination of the string. +*/ +int str_utf8_encode(char *ptr, int chr); + #ifdef __cplusplus } #endif -- cgit 1.4.1