Index: kernel/generic/include/string.h
===================================================================
--- kernel/generic/include/string.h	(revision b54d2f177d73478c2fc4d1d122eddfecc7393b6d)
+++ kernel/generic/include/string.h	(revision e1813cf4114a4d3ec284d7ebb2533fb7ce78e6fd)
@@ -38,10 +38,10 @@
 #include <typedefs.h>
 
-#define UTF8_NO_LIMIT  ((index_t) -1)
+#define UTF8_NO_LIMIT  ((size_t) -1)
 
 extern char invalch;
 
-extern wchar_t utf8_decode(const char *str, index_t *index, index_t limit);
-extern bool utf8_encode(const wchar_t ch, char *str, index_t *index, index_t limit);
+extern wchar_t chr_decode(const char *, size_t *, size_t);
+extern bool chr_encode(const wchar_t, char *, size_t *, size_t limit);
 extern size_t utf8_count_bytes(const char *str, count_t count);
 extern bool ascii_check(const wchar_t ch);
Index: kernel/generic/src/lib/string.c
===================================================================
--- kernel/generic/src/lib/string.c	(revision b54d2f177d73478c2fc4d1d122eddfecc7393b6d)
+++ kernel/generic/src/lib/string.c	(revision e1813cf4114a4d3ec284d7ebb2533fb7ce78e6fd)
@@ -57,20 +57,20 @@
 #define CONT_BITS 6
 
-/** Decode a single UTF-8 character from a NULL-terminated string.
- *
- * Decode a single UTF-8 character from a plain char NULL-terminated
- * string. Decoding starts at @index and this index is moved to the
- * beginning of the next character. In case of decoding error,
- * index advances. However, index is never moved beyond (str+limit).
- *
- * @param str   Plain character NULL-terminated string.
+/** Decode a single character from a substring.
+ *
+ * Decode a single character from a substring of size @a sz. Decoding starts
+ * at @a offset and this offset is moved to the beginning of the next
+ * character. In case of decoding error, offset generally advances at least
+ * by one. However, offset is never moved beyond (str + sz).
+ *
+ * @param str   String (not necessarily NULL-terminated).
  * @param index Index (counted in plain characters) where to start
  *              the decoding.
- * @param limit Maximal allowed value of index.
- *
- * @return Decoded character in UTF-32 or '?' if the encoding is wrong.
- *
- */
-wchar_t utf8_decode(const char *str, index_t *index, index_t limit)
+ * @param limit Size of the substring.
+ *
+ * @return	Value of decoded character or '?' on decoding error.
+ *
+ */
+wchar_t chr_decode(const char *str, size_t *offset, size_t sz)
 {
 	uint8_t b0, b;          /* Bytes read from str. */
@@ -80,8 +80,8 @@
 	int cbytes;		/* Number of continuation bytes. */
 
-	if (*index + 1 > limit)
+	if (*offset + 1 > sz)
 		return invalch;
 
-	b0 = (uint8_t) str[(*index)++];
+	b0 = (uint8_t) str[(*offset)++];
 
 	/* Determine code length. */
@@ -108,5 +108,5 @@
 	}
 
-	if (*index + cbytes > limit) {
+	if (*offset + cbytes > sz) {
 		return invalch;
 	}
@@ -116,5 +116,5 @@
 	/* Decode continuation bytes. */
 	while (cbytes > 0) {
-		b = (uint8_t) str[(*index)++];
+		b = (uint8_t) str[(*offset)++];
 
 		/* Must be 10xxxxxx. */
@@ -131,23 +131,20 @@
 }
 
-/** Encode a single UTF-32 character as UTF-8
- *
- * Encode a single UTF-32 character as UTF-8 and store it into
- * the given buffer at @index. Encoding starts at @index and
- * this index is moved at the position where the next character
- * can be written to.
- *
- * @param ch    Input UTF-32 character.
- * @param str   Output buffer.
- * @param index Index (counted in plain characters) where to start
- *              the encoding
- * @param limit Maximal allowed value of index.
- *
- * @return True if the character was encoded or false if there is not
- *         enought space in the output buffer or the character is invalid
- *         Unicode code point.
- *
- */
-bool utf8_encode(const wchar_t ch, char *str, index_t *index, index_t limit)
+/** Encode a single character to string representation.
+ *
+ * Encode a single character to string representation (i.e. UTF-8) and store
+ * it into a buffer at @a offset. Encoding starts at @a offset and this offset
+ * is moved to the position where the next character can be written to.
+ *
+ * @param ch		Input character.
+ * @param str		Output buffer.
+ * @param offset	Offset (in bytes) where to start writing.
+ * @param sz		Size of the output buffer.
+ *
+ * @return True if the character was encoded successfully or false if there
+ *	   was not enough space in the output buffer or the character code
+ *	   was invalid.
+ */
+bool chr_encode(const wchar_t ch, char *str, size_t *offset, size_t sz)
 {
 	uint32_t cc;		/* Unsigned version of ch. */
@@ -157,5 +154,5 @@
 	int i;
 
-	if (*index >= limit)
+	if (*offset >= sz)
 		return false;
 
@@ -185,18 +182,18 @@
 
 	/* Check for available space in buffer. */
-	if (*index + cbytes >= limit)
+	if (*offset + cbytes >= sz)
 		return false;
 
 	/* Encode continuation bytes. */
 	for (i = cbytes; i > 0; --i) {
-		str[*index + i] = 0x80 | (cc & LO_MASK_32(CONT_BITS));
+		str[*offset + i] = 0x80 | (cc & LO_MASK_32(CONT_BITS));
 		cc = cc >> CONT_BITS;
 	}
 
 	/* Encode first byte. */
-	str[*index] = (cc & LO_MASK_32(b0_bits)) | HI_MASK_8(8 - b0_bits - 1);
-
-	/* Advance index. */
-	*index += (1 + cbytes);
+	str[*offset] = (cc & LO_MASK_32(b0_bits)) | HI_MASK_8(8 - b0_bits - 1);
+
+	/* Advance offset. */
+	*offset += (1 + cbytes);
 	
 	return true;
@@ -227,5 +224,5 @@
 		if (size >= count)
 			break;
-		ch = utf8_decode(str, &index, UTF8_NO_LIMIT);
+		ch = chr_decode(str, &index, UTF8_NO_LIMIT);
 		if (ch == '\0') break;
 
@@ -289,5 +286,5 @@
 	index_t index = 0;
 	
-	while (utf8_decode(str, &index, UTF8_NO_LIMIT) != 0) {
+	while (chr_decode(str, &index, UTF8_NO_LIMIT) != 0) {
 		size++;
 	}
Index: kernel/generic/src/printf/printf_core.c
===================================================================
--- kernel/generic/src/printf/printf_core.c	(revision b54d2f177d73478c2fc4d1d122eddfecc7393b6d)
+++ kernel/generic/src/printf/printf_core.c	(revision e1813cf4114a4d3ec284d7ebb2533fb7ce78e6fd)
@@ -595,5 +595,5 @@
 	while (true) {
 		i = nxt;
-		uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT);
+		uc = chr_decode(fmt, &nxt, UTF8_NO_LIMIT);
 
 		if (uc == '\0') break;
@@ -619,5 +619,5 @@
 			do {
 				i = nxt;
-				uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT);
+				uc = chr_decode(fmt, &nxt, UTF8_NO_LIMIT);
 				switch (uc) {
 				case '#':
@@ -649,5 +649,5 @@
 
 					i = nxt;
-					uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT);
+					uc = chr_decode(fmt, &nxt, UTF8_NO_LIMIT);
 					if (uc == '\0')
 						break;
@@ -658,5 +658,5 @@
 				/* Get width value from argument list */
 				i = nxt;
-				uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT);
+				uc = chr_decode(fmt, &nxt, UTF8_NO_LIMIT);
 				width = (int) va_arg(ap, int);
 				if (width < 0) {
@@ -671,5 +671,5 @@
 			if (uc == '.') {
 				i = nxt;
-				uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT);
+				uc = chr_decode(fmt, &nxt, UTF8_NO_LIMIT);
 				if (isdigit(uc)) {
 					while (true) {
@@ -678,5 +678,5 @@
 
 						i = nxt;
-						uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT);
+						uc = chr_decode(fmt, &nxt, UTF8_NO_LIMIT);
 						if (uc == '\0')
 							break;
@@ -687,5 +687,5 @@
 					/* Get precision value from the argument list */
 					i = nxt;
-					uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT);
+					uc = chr_decode(fmt, &nxt, UTF8_NO_LIMIT);
 					precision = (int) va_arg(ap, int);
 					if (precision < 0) {
@@ -706,8 +706,8 @@
 				qualifier = PrintfQualifierShort;
 				i = nxt;
-				uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT);
+				uc = chr_decode(fmt, &nxt, UTF8_NO_LIMIT);
 				if (uc == 'h') {
 					i = nxt;
-					uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT);
+					uc = chr_decode(fmt, &nxt, UTF8_NO_LIMIT);
 					qualifier = PrintfQualifierByte;
 				}
@@ -717,8 +717,8 @@
 				qualifier = PrintfQualifierLong;
 				i = nxt;
-				uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT);
+				uc = chr_decode(fmt, &nxt, UTF8_NO_LIMIT);
 				if (uc == 'l') {
 					i = nxt;
-					uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT);
+					uc = chr_decode(fmt, &nxt, UTF8_NO_LIMIT);
 					qualifier = PrintfQualifierLongLong;
 				}
Index: kernel/generic/src/printf/vprintf.c
===================================================================
--- kernel/generic/src/printf/vprintf.c	(revision b54d2f177d73478c2fc4d1d122eddfecc7393b6d)
+++ kernel/generic/src/printf/vprintf.c	(revision e1813cf4114a4d3ec284d7ebb2533fb7ce78e6fd)
@@ -50,5 +50,5 @@
 	
 	while (index < size) {
-		putchar(utf8_decode(str, &index, size));
+		putchar(chr_decode(str, &index, size));
 		chars++;
 	}
@@ -75,5 +75,5 @@
 	wchar_t uc;
 	
-	while ((uc = utf8_decode(str, &index, UTF8_NO_LIMIT)) != 0) {
+	while ((uc = chr_decode(str, &index, UTF8_NO_LIMIT)) != 0) {
 		putchar(uc);
 		chars++;
Index: kernel/generic/src/printf/vsnprintf.c
===================================================================
--- kernel/generic/src/printf/vsnprintf.c	(revision b54d2f177d73478c2fc4d1d122eddfecc7393b6d)
+++ kernel/generic/src/printf/vsnprintf.c	(revision e1813cf4114a4d3ec284d7ebb2533fb7ce78e6fd)
@@ -85,7 +85,7 @@
 		
 		while (index < size) {
-			wchar_t uc = utf8_decode(str, &index, size);
+			wchar_t uc = chr_decode(str, &index, size);
 
-			if (!utf8_encode(uc, data->dst, &data->len, data->size - 1))
+			if (!chr_encode(uc, data->dst, &data->len, data->size - 1))
 				break;
 		}
@@ -147,5 +147,5 @@
 		}
 		
-		if (!utf8_encode(str[index], data->dst, &data->len, data->size - 1))
+		if (!chr_encode(str[index], data->dst, &data->len, data->size - 1))
 			break;
 		
