X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Ftitler%2Ftitler.C;h=67f88a96dc81180a26db43d9990421157045bfc9;hb=4c1a91d9f9373e564ecbeb8f568e4a3e7fe48e64;hp=aa4619fb1179c72f43948975cf5cfe7f46a5a290;hpb=efa5246e9610548448a6e4d505fdc6bdb5da84eb;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/plugins/titler/titler.C b/cinelerra-5.1/plugins/titler/titler.C index aa4619fb..67f88a96 100644 --- a/cinelerra-5.1/plugins/titler/titler.C +++ b/cinelerra-5.1/plugins/titler/titler.C @@ -2604,11 +2604,19 @@ void TitleMain::save_data(KeyFrame *keyframe) output.tag.set_property("LOOP_PLAYBACK", config.loop_playback); output.append_tag(); output.append_newline(); - char text[BCTEXTLEN]; + char text[2*sizeof(config.wtext)]; int text_len = BC_Resources::encode( BC_Resources::wide_encoding, DEFAULT_ENCODING, (char*)config.wtext, config.wlen*sizeof(wchar_t), text, sizeof(text)); + int len = output.length(), avail = MESSAGESIZE-16 - len; + if( text_len >= avail ) { // back off last utf8 char + text_len = avail; + while( text_len > 0 && (text[text_len-1] & 0xc0) == 0x80 ) + text[--text_len] = 0; + if( text_len > 0 ) + text[--text_len] = 0; + } output.append_text(text, text_len); output.tag.set_title("/TITLE"); output.append_tag();