diff --git a/src/vteconv.c b/src/vteconv.c
index e09d23b..35a6d57 100644
--- a/src/vteconv.c
+++ b/src/vteconv.c
@@ -42,14 +42,12 @@ struct _VteConv {
 static glong
 _vte_conv_utf8_strlen(const gchar *p, gssize max)
 {
-	const gchar *q = p;
-	glong length = 0;
-	while (q < p + max) {
-		q = g_utf8_next_char(q);
-		if (q <= p + max) {
-			length++;
-		}
-	}
+	const gchar *q = p + max;
+	glong length = -1;
+	do {
+		length++;
+		p = g_utf8_next_char(p);
+	} while (p < q);
 	return length;
 }
 
@@ -292,24 +290,19 @@ _vte_conv(VteConv converter,
 
 	/* Possibly convert the output from UTF-8 to gunichars. */
 	if (converter->out_unichar) {
-		int i, chars;
+		int  left = *outbytes_left;
 		char *p;
 		gunichar *g;
 
-		chars = _vte_conv_utf8_strlen(work_outbuf_start,
-					      work_outbuf_working - work_outbuf_start);
-		g_assert(*outbytes_left >= sizeof(gunichar) * chars);
-
-		p = work_outbuf_start;
 		g = (gunichar*) *outbuf;
-		for (i = 0; i < chars; i++) {
-		       g_assert(g_utf8_next_char(p) <= work_outbuf_working);
+		for(p = work_outbuf_start;
+			       	p < work_outbuf_working;
+			       	p = g_utf8_next_char(p)) {
+		       g_assert(left>=0);
 		       *g++ = g_utf8_get_char(p);
-		       p = g_utf8_next_char(p);
-		       g_assert(*outbytes_left >= sizeof(gunichar));
-		       *outbytes_left -= sizeof(gunichar);
-		       g_assert(p <= work_outbuf_working);
+					 left -= sizeof(gunichar);
 		}
+		*outbytes_left = left;
 		*outbuf = (gchar*) g;
 	} else {
 		/* Pass on the output results. */
