diff libaudacious/titlestring.c @ 1594:44f67f556b60 trunk

[svn] - precision in title format is regarded as character count, not byte count.
author yaz
date Thu, 24 Aug 2006 23:08:22 -0700
parents 705d4c089fce
children fda280358660
line wrap: on
line diff
--- a/libaudacious/titlestring.c	Thu Aug 24 14:55:06 2006 -0700
+++ b/libaudacious/titlestring.c	Thu Aug 24 23:08:22 2006 -0700
@@ -261,8 +261,17 @@
 
             /* Insert string. */
             if (precision >= 0) {
-                while (precision-- > 0 && (c = *string++) != '\0')
-                    PUTCH(c);
+                glong offset_max = precision, offset;
+                gchar *uptr = NULL;
+                const gchar *tmpstring = string;
+                while (precision > 0) {
+                    offset = offset_max - precision;
+                    uptr = g_utf8_offset_to_pointer(tmpstring, offset);
+                    if (*uptr == '\0')
+                        break;
+                    g_string_append_unichar(outstr, g_utf8_get_char(uptr));
+                    precision--;
+                }
             }
             else {
                 while ((c = *string++) != '\0')