Example #1
0
static void
gnac_playlist_resolve_uri_and_add(GFile *parent,
                                  gchar *filename)
{
    g_return_if_fail(filename);

    g_strstrip(filename);

    if (!g_utf8_validate(filename, -1, NULL)) {
        g_printerr("%s: %s\n", _("Invalid UTF-8 filename"), filename);
        return;
    }

    GFile *file;

    if (g_str_has_prefix(filename, "file://")) {
        file = g_file_new_for_uri(filename);
    } else {
        file = g_file_get_child(parent, filename);
    }

    gnac_add_file(file);
}
Example #2
0
gboolean
xmms_medialib_entry_property_set_str_source (xmms_medialib_session_t *session,
                                             xmms_medialib_entry_t id_num,
                                             const gchar *property, const gchar *value,
                                             const gchar *source)
{
	gboolean ret;
	s4_val_t *prop;

	g_return_val_if_fail (property, FALSE);

	if (value && !g_utf8_validate (value, -1, NULL)) {
		XMMS_DBG ("OOOOOPS! Trying to set property %s to a NON UTF-8 string (%s) I will deny that!", property, value);
		return FALSE;
	}

	prop = s4_val_new_string (value);
	ret = xmms_medialib_session_property_set (session, id_num, property, prop, source);
	s4_val_free (prop);

	return ret;

}
Example #3
0
char *
rsvg_make_valid_utf8 (const char *str, int len)
{
    GString *string;
    const char *remainder, *invalid;
    int remaining_bytes, valid_bytes;

    string = NULL;
    remainder = str;

    if (len < 0)
        remaining_bytes = strlen (str);
    else
        remaining_bytes = len;

    while (remaining_bytes != 0) {
        if (g_utf8_validate (remainder, remaining_bytes, &invalid))
            break;
        valid_bytes = invalid - remainder;

        if (string == NULL)
            string = g_string_sized_new (remaining_bytes);

        g_string_append_len (string, remainder, valid_bytes);
        g_string_append_c (string, '?');

        remaining_bytes -= valid_bytes + 1;
        remainder = invalid + 1;
    }

    if (string == NULL)
        return len < 0 ? g_strndup (str, len) : g_strdup (str);

    g_string_append (string, remainder);

    return g_string_free (string, FALSE);
}
Example #4
0
static char*
music_command_detect(const char *command, GError **err) {
	gchar *std_out, *std_err, *p, *cnv;
	gint exit_status;

	if (!g_spawn_command_line_sync(command,
			&std_out, &std_err, &exit_status, err))
		return NULL;

	if (exit_status != 0) {
		g_set_error(err, MUSIC_ERROR, MUSIC_COMMAND_ERROR, std_err);
		g_free(std_err);
		return NULL;
	}
	g_free(std_err);

	/* we take the first line of this output. */
	for (p = std_out; *p; p++) {
		if (*p == '\n') {
			*p = 0;
			break;
		}
	}
	if (p == std_out) {
		g_set_error(err, MUSIC_ERROR, MUSIC_COMMAND_ERROR,
				_("Command produced no output."));
		g_free(std_out);
		return NULL;
	}
	/* Check if result is correct UTF-8 */
	if (g_utf8_validate(std_out, -1, NULL))
		return std_out;
	/* Try converting from the current locale to UTF-8 */
	cnv = g_locale_to_utf8(std_out, -1, NULL, NULL, err);
	g_free(std_out);
	return cnv;
}
Example #5
0
char* iupgtkStrConvertFromUTF8(const char* str)  /* From GTK to IUP */
{
  if (!str || *str == 0)
    return (char*)str;

  if (iupgtk_utf8autoconvert)  /* this means str is in current locale */
  {
    const gchar *charset = NULL;
    if (g_get_charset(&charset)==TRUE)  /* current locale is already UTF-8 */
    {
      if (g_utf8_validate(str, -1, NULL))
        return (char*)str;
      else
      {
        if (gktLastConvertUTF8)
          g_free(gktLastConvertUTF8);
        gktLastConvertUTF8 = gtkStrFromUTF8(str, "ISO8859-1");  /* if string is not UTF-8, assume ISO8859-1 */
        if (!gktLastConvertUTF8) return (char*)str;
        return gktLastConvertUTF8;
      }
    }
    else
    {
      if (gtkStrIsAscii(str) || !charset)
        return (char*)str;
      else if (charset)
      {
        if (gktLastConvertUTF8)
          g_free(gktLastConvertUTF8);
        gktLastConvertUTF8 = gtkStrFromUTF8(str, charset);
        if (!gktLastConvertUTF8) return (char*)str;
        return gktLastConvertUTF8;
      }
    }
  }
  return (char*)str;
}
Example #6
0
static
gchar *sipmsg_uri_unescape(const gchar *string)
{
	gchar *unescaped, *tmp;

	if (!string) return(NULL);

#if GLIB_CHECK_VERSION(2,16,0)
	unescaped = g_uri_unescape_string(string, NULL);
#else
	/* loosely based on libpurple/util.c:purple_url_decode() */
	{
		gsize i = 0;
		gsize len = strlen(string);

		unescaped = g_malloc(len + 1);
		while (len-- > 0) {
			gchar c = *string++;
			if ((len >= 2) && (c == '%')) {
				char hex[3];
				strncpy(hex, string, 2);
				hex[2] = '\0';
				c = strtol(hex, NULL, 16);
				string += 2;
				len -= 2;
			}
			unescaped[i++] = c;
		}
		unescaped[i] = '\0';
	}
#endif

	if (!g_utf8_validate(unescaped, -1, (const gchar **)&tmp))
		*tmp = '\0';

	return(unescaped);
}
Example #7
0
static gchar *
window_get_utf8_property (GdkDisplay      *display,
                          GdkNativeWindow  window,
                          const gchar     *name)
{
  gchar   *retval = NULL;

#if defined(GDK_WINDOWING_X11)
  Atom     utf8_string;
  Atom     type   = None;
  guchar  *val    = NULL;
  gulong   nitems = 0;
  gulong   after  = 0;
  gint     format = 0;

  utf8_string = gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING");

  XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), window,
                      gdk_x11_get_xatom_by_name_for_display (display, name),
                      0, G_MAXLONG, False, utf8_string,
                      &type, &format, &nitems, &after, &val);

  if (type != utf8_string || format != 8 || nitems == 0)
    {
      if (val)
        XFree (val);
      return NULL;
    }

  if (g_utf8_validate ((const gchar *) val, nitems, NULL))
    retval = g_strndup ((const gchar *) val, nitems);

  XFree (val);

#endif
  return retval;
}
Example #8
0
File: UgUtils.c Project: Endz0/uget
// ------------------------------------------------------------------
// URI list functions
// get URIs from text file
GList*	ug_text_file_get_uris (const gchar* file_utf8, GError** error)
{
	GIOChannel*		channel;
	GList*			list;
	gchar*			string;
	gchar*			escaped;
	gsize			line_len;

	string = g_filename_from_utf8 (file_utf8, -1, NULL, NULL, NULL);
	channel = g_io_channel_new_file (string, "r", error);
	g_free (string);
	if (channel == NULL)
		return NULL;
	ug_io_channel_decide_encoding (channel);

	list = NULL;
	while (g_io_channel_read_line (channel, &string, NULL, &line_len, NULL) == G_IO_STATUS_NORMAL) {
		if (string == NULL)
			continue;
		string[line_len] = 0;		// clear '\n' in tail
		// check URI scheme
		if (ug_uri_scheme_len (string) == 0)
			g_free (string);
		else {
			// if URI is not valid UTF-8 string, escape it.
			if (g_utf8_validate (string, -1, NULL) == FALSE) {
				escaped = g_uri_escape_string (string,
						G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, FALSE);
				g_free (string);
				string = escaped;
			}
			list = g_list_prepend (list, string);
		}
	}
	g_io_channel_unref (channel);
	return g_list_reverse (list);
}
Example #9
0
const void *subsurface_get_conf(char *name)
{
	const int csize = 64;
	int blen = 0;
	LONG ret = ERROR_MORE_DATA;
	wchar_t *wstring = NULL, *wname = NULL;
	char *utf8_string;

	wname = (wchar_t *)g_utf8_to_utf16(name, -1, NULL, NULL, NULL);
	if (!wname)
		return NULL;
	blen = 0;
	/* lest try to load the string in chunks of 'csize' bytes until it fits */
	while(ret == ERROR_MORE_DATA) {
		blen += csize;
		wstring = (wchar_t *)realloc(wstring, blen * sizeof(wchar_t));
		ret = RegQueryValueExW(hkey, (LPCWSTR)wname, NULL, NULL,
		                     (LPBYTE)wstring, (LPDWORD)&blen);
	}
	/* that's what happens the first time we start - just return NULL */
	if (ret != ERROR_SUCCESS) {
		free(wname);
		free(wstring);
		return NULL;
	}
	/* convert the returned string into utf-8 */
	utf8_string = g_utf16_to_utf8(wstring, -1, NULL, NULL, NULL);
	free(wstring);
	free(wname);
	if (!utf8_string)
		return NULL;
	if (!g_utf8_validate(utf8_string, -1, NULL)) {
		free(utf8_string);
		return NULL;
	}
	return utf8_string;
}
static gchar *
get_image_version_for_path (const gchar *path)
{
  ssize_t xattr_size;
  g_autofree gchar *image_version = NULL;

  xattr_size = getxattr (path, EOS_IMAGE_VERSION_XATTR, NULL, 0);

  if (xattr_size < 0 || xattr_size > SSIZE_MAX - 1)
    return NULL;

  image_version = g_malloc0 (xattr_size + 1);

  xattr_size = getxattr (path, EOS_IMAGE_VERSION_XATTR,
                         image_version, xattr_size);

  /* this check is primarily for ERANGE, in case the attribute size has
   * changed from the first call to this one */
  if (xattr_size < 0)
    {
      g_warning ("Error when getting 'eos-image-version' from %s: %s", path,
                 strerror (errno));
      return NULL;
    }

  /* shouldn't happen, but if the filesystem is modified or corrupted, we
   * don't want to cause assertion errors / D-Bus disconnects with invalid
   * UTF-8 strings */
  if (!g_utf8_validate (image_version, xattr_size, NULL))
    {
      g_warning ("Invalid UTF-8 when getting 'eos-image-version' from %s",
                 path);
      return NULL;
    }

  return g_steal_pointer (&image_version);
}
Example #11
0
File: msg.c Project: spk121/jozabad
// Addresses are 1 to 16 codepoints, and must start and end
// with a non-space codepoint
gboolean address_validate (gchar *str)
{
  glong len;
  gchar *p;

  if (str == NULL)
    return FALSE;
  if (!g_utf8_validate (str, -1, NULL))
    return FALSE;
  len = g_utf8_strlen (str, -1);
  if (len == 0 || len > JZ_MSG_MAX_ADDRESS_LENGTH)
  return FALSE;
  
p = str;
for (glong i = 0; i < len; i ++)
  {
    if ((i == 0 || i == len - 1) && (!g_unichar_isgraph (g_utf8_get_char (p))))
      return FALSE;
    else if (!g_unichar_isprint (g_utf8_get_char (p)))
      return FALSE;
    p = g_utf8_next_char (p);
  }
return TRUE;
}
Example #12
0
File: UgUri.c Project: Endz0/uget
// --------------------------------------------------------
// Convenience Functions for UgUri
gchar*	ug_uri_get_file (UgUri* upart)
{
	const char*	str;
	char*		name;
	int			len;

	if ((len = ug_uri_part_file (upart, &str)) == 0)
		return NULL;
	name = g_uri_unescape_segment (str, str+len, NULL);
	if (name == NULL)
		name = g_strndup (str, len);
	// check encoding
	if (g_utf8_validate (name, -1, NULL) == FALSE) {
		str = g_locale_to_utf8 (name, -1, NULL, NULL, NULL);
		if (str == NULL) {
			str = g_uri_escape_string (name,
					G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT, FALSE);
		}
		g_free (name);
		return (gchar*) str;
	}

	return name;
}
Example #13
0
Glib::ustring FormatToUTF8::guessEncoding(const std::string& s)
{
	Glib::ustring res_unused ;
	std::string locale_unused ;
	bool converted ;

	//> case 1 : UTF8
	Glib::ustring encoding = "UTF-8" ;
	bool utf8 = g_utf8_validate(s.c_str(), -1, NULL) ;
	if (utf8)
		return encoding ;

	//> case 2 : ISO-8859-1
	encoding = "ISO-8859-1" ;
	converted = convertFromEncodingToUTF8(s, encoding, res_unused) ;
	if (converted)
		return encoding ;

	//> case 3 : ISO-8859-15
	encoding = "ISO-8859-15" ;
	converted = convertFromEncodingToUTF8(s, encoding, res_unused) ;
	if (converted)
		return encoding ;

	//> case 5 : CPP-1252
	encoding = "CPP-1252" ;
	converted = convertFromEncodingToUTF8(s, encoding, res_unused) ;
	if (converted)
		return encoding ;

	// TODO add all others encoding ?

	//> other cases: not found
	TRACE << "no encoding found" << std::endl ;
	return "" ;
}
static GValue *
str_to_gvalue (const char *str, gboolean try_convert)
{
	GValue *val;

	/* Empty */
	if (!str || strlen (str) < 1)
		return NULL;

	if (!g_utf8_validate (str, -1, NULL)) {
		if (try_convert && !(str = g_convert (str, -1, "ISO-8859-1", "UTF-8", NULL, NULL, NULL)))
			str = g_convert (str, -1, "C", "UTF-8", NULL, NULL, NULL);

		if (!str)
			/* Invalid */
			return NULL;
	}

	val = g_slice_new0 (GValue);
	g_value_init (val, G_TYPE_STRING);
	g_value_set_string (val, str);

	return val;
}
Example #15
0
static char *
fix_utf8(const char *str, size_t length)
{
	const gchar *end;
	char *temp;
	gsize written;

	assert(str != NULL);

	/* check if the string is already valid UTF-8 */
	if (g_utf8_validate(str, length, &end))
		return NULL;

	/* no, it's not - try to import it from ISO-Latin-1 */
	temp = g_convert(str, length, "utf-8", "iso-8859-1",
			 NULL, &written, NULL);
	if (temp != NULL)
		/* success! */
		return temp;

	/* no, still broken - there's no medication, just patch
	   invalid sequences */
	return patch_utf8(str, length, end);
}
/* The following two charset mangling functions were copied from gnomevfssrc.
 * Preserve them under the unverified assumption that they do something vaguely
 * worthwhile.
 */
static gchar *
unicodify (const gchar * str, gint len, ...)
{
    gchar *ret = NULL, *cset;
    va_list args;
    gsize bytes_read, bytes_written;

    if (g_utf8_validate (str, len, NULL))
        return g_strndup (str, len >= 0 ? len : strlen (str));

    va_start (args, len);
    while ((cset = va_arg (args, gchar *)) != NULL) {
        if (!strcmp (cset, "locale"))
            ret = g_locale_to_utf8 (str, len, &bytes_read, &bytes_written, NULL);
        else
            ret = g_convert (str, len, "UTF-8", cset,
                             &bytes_read, &bytes_written, NULL);
        if (ret)
            break;
    }
    va_end (args);

    return ret;
}
Example #17
0
static int
str_utf8_length (const char *text)
{
    int result = 0;
    const char *start;
    const char *end;

    start = text;
    while (!g_utf8_validate (start, -1, &end) && start[0] != '\0')
    {
        if (start != end)
            result += g_utf8_strlen (start, end - start);

        result++;
        start = end + 1;
    }

    if (start == text)
        result = g_utf8_strlen (text, -1);
    else if (start[0] != '\0' && start != end)
        result += g_utf8_strlen (start, end - start);

    return result;
}
Example #18
0
static char *
get_display_name (GFile     *file,
                  GFileInfo *info)
{
  char *name, *tmp;

  name = NULL;
  if (info)
    name = g_strdup (g_file_info_get_display_name (info));

  if (name == NULL)
    {
      name = g_file_get_basename (file);
      if (!g_utf8_validate (name, -1, NULL))
        {
          tmp = name;
          name =
            g_uri_escape_string (name, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, TRUE);
          g_free (tmp);
        }
    }

  return name;
}
Example #19
0
gboolean
mu_util_fputs_encoded (const char *str, FILE *stream)
{
	int rv;
	unsigned	 bytes;
	char		*conv;

	g_return_val_if_fail (str, FALSE);
	g_return_val_if_fail (stream, FALSE);

	/* g_get_charset return TRUE when the locale is UTF8 */
	if (mu_util_locale_is_utf8())
		return fputs (str, stream) == EOF ? FALSE : TRUE;

	 /* charset is _not_ utf8, so we actually have to convert
	  * it
	  */
	conv = NULL;
	if (g_utf8_validate (str, -1, NULL))
		/* it _seems_ that on the bsds, the final err param
		 * may receive garbage... so we don't use it */
		conv = g_locale_from_utf8
			(str, -1, (gsize*)&bytes, NULL, NULL);

	/* conversion failed; this happens because is some cases GMime
	 * may gives us non-UTF-8 strings from e.g. wrongly encoded
	 * message-subjects; if so, we escape the string
	 */
	if (!conv)
		conv = g_strescape (str, "\n\t");

	rv  = conv ? fputs (conv, stream) : EOF;
	g_free (conv);

	return (rv == EOF) ? FALSE : TRUE;
}
Example #20
0
static GString *g_string_append_escaped(GString *string, char *data)
{
	const char* end;

	if (!g_utf8_validate(data, -1, &end)) {
		return NULL;
	}

	while (data != end) {
		gunichar ch = g_utf8_get_char(data);

		if (ch <= 127) {
			if (isalpha(ch) || isdigit(ch) ||
					ch == '-' || ch == '_' || ch == '.' || ch == '!' ||
					ch == '~' || ch == '*' || ch == '\'' || ch == '(' || ch == ')') {
				g_string_append_c(string, ch);
			} else if (ch == ' ') {
				g_string_append_c(string, '+');
			} else {
				g_string_append_printf(string, "%%%02x", ch);
			}
		}
		else {
			char out[6];
			gint length = g_unichar_to_utf8(ch, out);

			for (size_t i = 0; i < length; i++) {
				g_string_append_printf(string, "%%%02x", out[i] & 0xff);
			}
		}

		data = g_utf8_next_char(data);
	}

	return string;
}
Example #21
0
static gchar* convert_2_utf8(gchar* locale) {
    gsize read, write;
    GError* error = NULL;
    gchar *current, *utf8;
    const gchar* charset;

    if (g_get_charset(&charset) || g_utf8_validate(locale, -1, 0))
        return g_strdup(locale);

    if (strcmp("ANSI_X3.4-1968", charset) == 0)
        current = g_strdup("ISO-8859-1");
    else
        current = g_strdup(charset);

    utf8 = g_convert(locale, -1, "UTF-8", current, &read, &write, &error);
    if (error) {
        g_warning("Failed to convert [%s]: %s", charset, error->message);
        g_free(current);
        return NULL;
    }
    g_free(current);

    return utf8;
}
Example #22
0
gboolean
xmms_xform_metadata_set_str (xmms_xform_t *xform, const char *key,
                             const char *val)
{
	const char *old;

	if (!g_utf8_validate (val, -1, NULL)) {
		xmms_log_error ("xform '%s' tried to set property '%s' to a NON UTF-8 string!", xmms_xform_shortname (xform), key);
		return FALSE;
	}

	if (xmms_xform_metadata_get_str (xform, key, &old)) {
		if (strcmp (old, val) == 0) {
			return TRUE;
		}
	}

	g_hash_table_insert (xform->metadata, g_strdup (key),
	                     xmmsv_new_string (val));

	xform->metadata_changed = TRUE;

	return TRUE;
}
Example #23
0
static gchar *
gst_hls_src_buf_to_utf8_playlist (GstBuffer * buf)
{
  GstMapInfo info;
  gchar *playlist;

  if (!gst_buffer_map (buf, &info, GST_MAP_READ))
    goto map_error;

  if (!g_utf8_validate ((gchar *) info.data, info.size, NULL))
    goto validate_error;

  /* alloc size + 1 to end with a null character */
  playlist = g_malloc0 (info.size + 1);
  memcpy (playlist, info.data, info.size);

  gst_buffer_unmap (buf, &info);
  return playlist;

validate_error:
  gst_buffer_unmap (buf, &info);
map_error:
  return NULL;
}
static gssize
tny_pixbuf_write_to_stream_default (TnyStream *self, TnyStream *output)
{
	char tmp_buf[4096];
	gssize total = 0;
	gssize nb_read;
	gssize nb_written;

	g_assert (TNY_IS_STREAM (output));

	while (G_LIKELY (!tny_stream_is_eos (self))) 
	{
		nb_read = tny_stream_read (self, tmp_buf, sizeof (tmp_buf));
		if (G_UNLIKELY (nb_read < 0))
			return -1;
		else if (G_LIKELY (nb_read > 0)) {
			const gchar *end;
			if (!g_utf8_validate (tmp_buf, nb_read, &end)) 
				g_warning ("utf8 invalid: %d of %d", (gint)nb_read,
					   (gint)(end - tmp_buf));
				
			nb_written = 0;
	
			while (G_LIKELY (nb_written < nb_read))
			{
				gssize len = tny_stream_write (output, tmp_buf + nb_written,
								  nb_read - nb_written);
				if (G_UNLIKELY (len < 0))
					return -1;
				nb_written += len;
			}
			total += nb_written;
		}
	}
	return total;
}
Example #25
0
static void handle_input_filename(const gchar *buf)
{
	gchar *utf8_filename, *locale_filename;

	/* we never know how the input is encoded, so do the best auto detection we can */
	if (! g_utf8_validate(buf, -1, NULL))
		utf8_filename = encodings_convert_to_utf8(buf, -1, NULL);
	else
		utf8_filename = g_strdup(buf);

	locale_filename = utils_get_locale_from_utf8(utf8_filename);
	if (locale_filename)
	{
		if (g_str_has_suffix(locale_filename, ".geany"))
		{
			if (project_ask_close())
				main_load_project_from_command_line(locale_filename, TRUE);
		}
		else
			main_handle_filename(locale_filename);
	}
	g_free(utf8_filename);
	g_free(locale_filename);
}
Example #26
0
void yahoo_process_conference_logon(PurpleConnection *gc, struct yahoo_packet *pkt)
{
	GSList *l;
	char *room = NULL;
	char *who = NULL;
	PurpleChatConversation *c;

	for (l = pkt->hash; l; l = l->next) {
		struct yahoo_pair *pair = l->data;

		switch (pair->key) {
		case 57:
			g_free(room);
			room = yahoo_string_decode(gc, pair->value, FALSE);
			break;
		case 53:
			if (g_utf8_validate(pair->value, -1, NULL)) {
				who = pair->value;
			} else {
				purple_debug_warning("yahoo", "yahoo_process_conference_logon "
						"got non-UTF-8 string for key %d\n", pair->key);
			}
			break;
		}
	}

	if (who && room) {
		c = yahoo_find_conference(gc, room);
		if (c)
		{	/* Prevent duplicate users in the chat */
			if( !purple_chat_conversation_has_user(c, who) )
				yahoo_chat_add_user(c, who, NULL);
		}
		g_free(room);
	}
}
Example #27
0
static char *name2utf8(const uint8_t *name, uint16_t len)
{
	char utf8_name[HCI_MAX_NAME_LENGTH + 2];
	int i;

	if (g_utf8_validate((const char *) name, len, NULL))
		return g_strndup((char *) name, len);

	len = MIN(len, sizeof(utf8_name) - 1);

	memset(utf8_name, 0, sizeof(utf8_name));
	strncpy(utf8_name, (char *) name, len);

	/* Assume ASCII, and replace all non-ASCII with spaces */
	for (i = 0; utf8_name[i] != '\0'; i++) {
		if (!isascii(utf8_name[i]))
			utf8_name[i] = ' ';
	}

	/* Remove leading and trailing whitespace characters */
	g_strstrip(utf8_name);

	return g_strdup(utf8_name);
}
Example #28
0
void msgwin_compiler_add_string(gint msg_color, const gchar *msg)
{
	GtkTreeIter iter;
	const GdkColor *color = get_color(msg_color);
	gchar *utf8_msg;

	if (! g_utf8_validate(msg, -1, NULL))
		utf8_msg = utils_get_utf8_from_locale(msg);
	else
		utf8_msg = (gchar *) msg;

	gtk_list_store_append(msgwindow.store_compiler, &iter);
	gtk_list_store_set(msgwindow.store_compiler, &iter,
		COMPILER_COL_COLOR, color, COMPILER_COL_STRING, utf8_msg, -1);

	/* Lazily initialize the line shifts hash table once we get a non-status compiler message */
	if (msg_color != COLOR_BLUE && msgwindow.line_shifts_compiler == NULL)
		msgwindow.line_shifts_compiler = g_hash_table_new_full(g_str_hash, g_str_equal,
			g_free, free_line_shifts_seq);

	if (ui_prefs.msgwindow_visible && interface_prefs.compiler_tab_autoscroll)
	{
		GtkTreePath *path = gtk_tree_model_get_path(
			gtk_tree_view_get_model(GTK_TREE_VIEW(msgwindow.tree_compiler)), &iter);

		gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(msgwindow.tree_compiler), path, NULL, TRUE, 0.5, 0.5);
		gtk_tree_path_free(path);
	}

	/* calling build_menu_update for every build message would be overkill, TODO really should call it once when all done */
	gtk_widget_set_sensitive(build_get_menu_items(-1)->menu_item[GBG_FIXED][GBF_NEXT_ERROR], TRUE);
	gtk_widget_set_sensitive(build_get_menu_items(-1)->menu_item[GBG_FIXED][GBF_PREV_ERROR], TRUE);

	if (utf8_msg != msg)
		g_free(utf8_msg);
}
static void
gst_split_file_src_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
{
  GstSplitFileSrc *src = GST_SPLIT_FILE_SRC (object);

  switch (prop_id) {
    case PROP_LOCATION:
      GST_OBJECT_LOCK (src);
      g_free (src->location);
      src->location = g_value_dup_string (value);
#ifdef G_OS_WIN32
      if (!g_utf8_validate (src->location, -1, NULL)) {
        g_warning ("splitfilesrc 'location' property must be in UTF-8 "
            "encoding on Windows");
      }
#endif
      GST_OBJECT_UNLOCK (src);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}
gchar *
translate_day(const gint weekday)
{
    struct tm time_tm;
    gchar *day_loc;
    int len;

    if (weekday < 0 || weekday > 6)
        return NULL;

    time_tm.tm_wday = weekday;

    day_loc = g_malloc(DAY_LOC_N);

    len = strftime(day_loc, DAY_LOC_N, "%A", &time_tm);
    day_loc[len] = 0;
    if (!g_utf8_validate(day_loc, -1, NULL)) {
        gchar *utf8 = g_locale_to_utf8(day_loc, -1, NULL, NULL, NULL);
        g_free(day_loc);
        day_loc = utf8;
    }

    return day_loc;
}