about summary refs log tree commit diff
path: root/src/base/system.h
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2009-06-13 08:22:37 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2009-06-13 08:22:37 +0000
commit69511102de9b0f3ec6ad555baf2a01d9ee1c3dfd (patch)
treeebef66e5ab0cfd16e96026d8ac8d5a708eb68219 /src/base/system.h
parent9254ca61f1e459cbaf137ce4511332365da9c225 (diff)
downloadzcatch-69511102de9b0f3ec6ad555baf2a01d9ee1c3dfd.tar.gz
zcatch-69511102de9b0f3ec6ad555baf2a01d9ee1c3dfd.zip
improved the font system even futher. utf8 is now used everywhere. it uses less memory as well
Diffstat (limited to 'src/base/system.h')
-rw-r--r--src/base/system.h63
1 files changed, 63 insertions, 0 deletions
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