diff --git a/glib/gunicollate.c b/glib/gunicollate.c
index 3649786..1d0826a 100644
--- a/glib/gunicollate.c
+++ b/glib/gunicollate.c
@@ -217,29 +217,22 @@ collate_key_to_string (UCCollationValue *key,
                        gsize             key_len)
 {
   gchar *result;
-  gsize result_len;
-  gsize i;
+  gsize result_len = 0;
+  gsize i, start;
 
-  /* Pretty smart algorithm here: ignore first eight bytes of the
-   * collation key. It doesn't produce results equivalent to
-   * UCCompareCollationKeys's, but the difference seems to be only
-   * that UCCompareCollationKeys in some cases produces 0 where our
-   * comparison gets -1 or 1. */
+  /* skip the first block of values until the first 0 */
+  for (i = 0; i < key_len && key[i] != 0; i++);
+  start = i + 1;
 
-  if (key_len * sizeof (UCCollationValue) <= 8)
-    return g_strdup ("");
-
-  result_len = 0;
-  for (i = 8; i < key_len * sizeof (UCCollationValue); i++)
-    /* there may be nul bytes, encode byteval+1 */
-    result_len += utf8_encode (NULL, *((guchar*)key + i) + 1);
+  for (i = start; i < key_len; i++)
+    result_len += utf8_encode (NULL, htonl(key[i]));
 
   result = g_malloc (result_len + 1);
   result_len = 0;
-  for (i = 8; i < key_len * sizeof (UCCollationValue); i++)
-    result_len += utf8_encode (result + result_len, *((guchar*)key + i) + 1);
+  for (i = start; i < key_len; i++)
+    result_len += utf8_encode (result + result_len, htonl(key[i]));
 
-  result[result_len] = 0;
+  result[result_len] = '\0';
   return result;
 }
 
