[vlc-devel] [PATCH] UTF-16 chapter titles (reworked)

Donald Campbell donaciano2000 at gmail.com
Sun Jul 3 21:05:14 CEST 2016


Suggestions applied, using FromCharset now instead.  Tested on OS X, no warnings, properly shows text and is much cleaner.  

Thanks,
-DC
P.S.  I’ve turned off digest mode so I can properly continue the thread from now on.

---
 modules/demux/mp4/mp4.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 79c28a7..998196f 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -1854,7 +1854,12 @@ static void LoadChapterApple( demux_t  *p_demux, mp4_track_t *tk )
             {
                 seekpoint_t *s = vlc_seekpoint_New();
 
-                s->psz_name = strndup( &p_buffer[2], i_len );
+                if(*(&p_buffer[2])==(char)255 && *(&p_buffer[2]+1)==(char)254){ // UTF-16 BOM
+                    s->psz_name = FromCharset("UTF-16LE", &p_buffer[2], i_len);
+                } else {  // non UTF-16 strings
+                    s->psz_name = strndup( &p_buffer[2], i_len );
+                }
+
                 EnsureUTF8( s->psz_name );
 
                 s->i_time_offset = i_dts + __MAX( i_pts_delta, 0 );
-- 
2.7.4 (Apple Git-66)


More information about the vlc-devel mailing list