1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/bl/utf8.c Wed Oct 02 23:51:18 2013 +0100
1.3 @@ -0,0 +1,24 @@
1.4 +#include <stdlib.h>
1.5 +#include <string.h>
1.6 +#include <glib.h>
1.7 +#include <bl/bl.h>
1.8 +
1.9 +/*
1.10 + * Creates a new string length bytes long filled with fill_char.
1.11 + * The returned string should be freed when no longer needed.
1.12 + */
1.13 +gchar *utf8_strnfill(gsize length,gunichar fill_char)
1.14 +{
1.15 + int n,i;
1.16 + gchar *s;
1.17 + char utf8[6];
1.18 + n=g_unichar_to_utf8(fill_char,utf8);
1.19 + s=g_new(gchar,length*n+1);
1.20 + if (n==1)
1.21 + memset(s,utf8[0],length);
1.22 + else
1.23 + for(i=0;i<length;i++)
1.24 + memcpy(s+i*n,utf8,n);
1.25 + s[length*n]='\0';
1.26 + return s;
1.27 +}