[gst-devel] metadata and charsets

Colin Walters walters at debian.org
Sun Feb 16 10:40:05 CET 2003


On Thu, 2003-02-13 at 00:45, Colin Walters wrote:

> So I think GStreamer should convert everything to UTF-8.

I just changed gstgnomevfssrc to convert stuff to UTF-8.  In the process
I wrote this handy little function which lets you try converting a
string into UTF-8 from a bunch of charsets at a time, like:

utf8str = unicodify (buf, -1, "locale", "ISO-8859-1", "EUC-JP", NULL);

What do you guys think about putting this in gstutils.c, for wider use
among plugins?

char *
unicodify (const char *str, int len, ...)
{
	char *ret = NULL, *cset;
	va_list args;
	int 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, char *)) != 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;
}





More information about the gstreamer-devel mailing list