mpegtspacketizer: support more character set encodings

Support UTF-16BE, EUC-KR (KSX1001), GB2312 and ISO-10646/UTF8 text
encoding and fixed new line for multibyte encoding
    
https://bugzilla.gnome.org/show_bug.cgi?id=664257

(Port of 9759d66407 from the mpegtsdemux
element)
This commit is contained in:
Thibault Saunier 2012-02-27 09:42:27 -03:00
parent 336710d355
commit 58a210e3d3

View file

@ -2542,13 +2542,22 @@ get_encoding (const gchar * text, guint * start_text, gboolean * is_multibyte)
*start_text = 1; *start_text = 1;
*is_multibyte = TRUE; *is_multibyte = TRUE;
} else if (firstbyte == 0x12) { } else if (firstbyte == 0x12) {
/* That's korean encoding. /* EUC-KR implements KSX1001 */
* The spec says it's encoded in KSC 5601, but iconv only knows KSC 5636. encoding = g_strdup ("EUC-KR");
* Couldn't find any information about either of them.
*/
encoding = NULL;
*start_text = 1; *start_text = 1;
*is_multibyte = TRUE; *is_multibyte = TRUE;
} else if (firstbyte == 0x13) {
encoding = g_strdup ("GB2312");
*start_text = 1;
*is_multibyte = FALSE;
} else if (firstbyte == 0x14) {
encoding = g_strdup ("UTF-16BE");
*start_text = 1;
*is_multibyte = TRUE;
} else if (firstbyte == 0x15) {
encoding = g_strdup ("ISO-10646/UTF8");
*start_text = 1;
*is_multibyte = FALSE;
} else { } else {
/* reserved */ /* reserved */
encoding = NULL; encoding = NULL;
@ -2600,7 +2609,7 @@ convert_to_utf8 (const gchar * text, gint length, guint start,
/* skip it */ /* skip it */
break; break;
case 0xE08A:{ case 0xE08A:{
guint8 nl[] = { 0x0A, 0x00 }; /* new line */ guint8 nl[] = { 0x00, 0x0A }; /* new line */
g_byte_array_append (sb, nl, 2); g_byte_array_append (sb, nl, 2);
break; break;
} }
@ -2621,7 +2630,7 @@ convert_to_utf8 (const gchar * text, gint length, guint start,
/* skip it */ /* skip it */
break; break;
case 0xE08A:{ case 0xE08A:{
guint8 nl[] = { 0x0A, 0x00 }; /* new line */ guint8 nl[] = { 0x00, 0x0A }; /* new line */
g_byte_array_append (sb, nl, 2); g_byte_array_append (sb, nl, 2);
break; break;
} }