burn-plugin: UTF converting
Commit Message
Hi,
I wondered about converting to UTF8 ( EscapeLatin1toUTF8() ). What's about
another codepages?
Here is patch that must working for all cases....
Cheers
Oleg
Comments
Hi,
Oleg wrote:
> Hi,
>
> I wondered about converting to UTF8 ( EscapeLatin1toUTF8() ). What's about
> another codepages?
I tried your patch as I'd need it for ISO_8859-2.
> Here is patch that must working for all cases....
>
What VDR version are you using? It doesmn't work for several 1.3.x
versions because of the following:
> +char *Convert2UTF(const char *Text)
> +{
> + const char *f = I18nCharSet(Setup.OSDLanguage);
^^^^
this has changed at some version to
const char *f = I18nCharSets()[Setup.OSDLanguage];
^^^^^
But neveretheless, even if it now compiles with the latest VDR, the
plugin crashes when it starts rendering the text into the DVD menu
images. At least on my not-yet-UTF-8 ready system Is this a requirement,
to get my system UTF-8 compliant? Does VDR also need its own UTF-8 patch
(Alexander Riedel posted the last version 0.0.3b with Freetype2 for
vdr-1.3.27 on 2005.07.23, maybe I should also try to make this one work
with current VDR)? So, Oleg, how did you make it work?
Regards,
Lucian
On Monday 24 October 2005 11:45, Lucian Muresan wrote:
> What VDR version are you using? It doesmn't work for several 1.3.x
>
> versions because of the following:
> > +char *Convert2UTF(const char *Text)
> > +{
> > + const char *f = I18nCharSet(Setup.OSDLanguage);
>
> ^^^^
> this has changed at some version to
>
> const char *f = I18nCharSets()[Setup.OSDLanguage];
> ^^^^^
Sorry. I have copy this function from UTF patch
---------------------------------------------------------------------------------------------------------
const char * I18nCharSet(int Index)
{
return 0 <= Index && Index < I18nNumLanguages ? Phrases[1][Index] : NULL;
}
--------------------------------------------------------------------------------------------------------
Also you can use a macro tr()
const char *f = tr ("iso8859-1"); instead of I18nCharSet()
Best Regards
Oleg
@@ -11,6 +11,8 @@
#include "setup.h"
#include <vdr/recording.h>
#include <sys/types.h>
+#include <iconv.h>
+#include <vdr/i18n.h>
const char *BurnStates[__STATE_COUNT__] = { "List", "Status" };
const char *DiskTypes[__TYPE_COUNT__] = { "DVD with menus", "DVD without menus", "Archive disk" };
@@ -154,3 +156,43 @@
*out = 0;
return utf;
}
+
+char *Convert2UTF(const char *Text)
+{
+ const char *f = I18nCharSet(Setup.OSDLanguage);
+ const char *from = MALLOC( char,11 );
+
+ if(!strcasecmp(f,"iso8859-1")) from = "ISO_8859-1";
+ else if(!strcasecmp(f,"iso8859-2")) from = "ISO_8859-2";
+ else if(!strcasecmp(f,"iso8859-3")) from = "ISO_8859-3";
+ else if(!strcasecmp(f,"iso8859-4")) from = "ISO_8859-4";
+ else if(!strcasecmp(f,"iso8859-5")) from = "ISO_8859-5";
+ else if(!strcasecmp(f,"iso8859-6")) from = "ISO_8859-6";
+ else if(!strcasecmp(f,"iso8859-7")) from = "ISO_8859-7";
+ else if(!strcasecmp(f,"iso8859-8")) from = "ISO_8859-8";
+ else if(!strcasecmp(f,"iso8859-9")) from = "ISO_8859-9";
+ else if(!strcasecmp(f,"iso8859-10")) from = "ISO_8859-10";
+ else if(!strcasecmp(f,"iso8859-11")) from = "ISO_8859-11";
+ else if(!strcasecmp(f,"iso8859-12")) from = "ISO_8859-12";
+ else if(!strcasecmp(f,"iso8859-13")) from = "ISO_8859-13";
+ else if(!strcasecmp(f,"iso8859-14")) from = "ISO_8859-14";
+ else if(!strcasecmp(f,"iso8859-15")) from = "ISO_8859-15";
+
+ iconv_t ic = iconv_open("UTF8", from );
+ if(ic >= 0) {
+ size_t inbytesleft = sizeof(Text);
+ size_t outbytesleft;
+ size_t ret;
+ char *out= MALLOC(char, inbytesleft * 4 + 1);;
+ if( (ret=iconv(ic,(char**)&Text, &inbytesleft, &out, &outbytesleft)) >= 0 ) {
+ iconv_close(ic);
+ return out;
+ }
+
+ }
+ else {
+ return (char*)Text;
+ }
+
+}
+
@@ -147,5 +147,6 @@
const tTrackInfoArray& FindTitleTracks(const char *Path);
char *EscapeLatin1toUTF8(const char *Text);
+char *Convert2UTF(const char *Text);
#endif // VDR_BURN_COMMON_H
@@ -233,14 +233,14 @@
DrawImage(mBackground, 0, 0);
- next = EscapeLatin1toUTF8(tr("Next page"));
- prev = EscapeLatin1toUTF8(tr("Previous page"));
+ next = Convert2UTF(tr("Next page"));
+ prev = Convert2UTF(tr("Previous page"));
for (int i = p * MAXPAGETITLES, j = 0;
i < min(p * MAXPAGETITLES + MAXPAGETITLES, mJob->Count());
++i, ++j) {
cBurnRecording *rec = mJob->Get(i);
- char *name = EscapeLatin1toUTF8(rec->Name());
+ char *name = Convert2UTF(rec->Name());
if (BurnSetup.RenderRecordingIndex) {
char *indexedName;
asprintf(&indexedName, "%d. %s", i+1, name);
@@ -250,7 +250,7 @@
DrawText(name, 138, 124 + j * 40, 450, 30);
free(name);
}
- char *name = EscapeLatin1toUTF8(mJob->Title());
+ char *name = Convert2UTF(mJob->Title());
DrawText(name, 138, 52, 450, 30);
free(name);
@@ -348,13 +348,13 @@
DrawImage(mBackground, 0, 0);
- stitle = EscapeLatin1toUTF8(tr("DESCRIPTION OF FILMTITLE"));
- summary = EscapeLatin1toUTF8(mRecording->Summary() ? mRecording->Summary()
+ stitle = Convert2UTF(tr("DESCRIPTION OF FILMTITLE"));
+ summary = Convert2UTF(mRecording->Summary() ? mRecording->Summary()
: mRecording->Name());
- play = EscapeLatin1toUTF8(tr("Play movie"));
- back = EscapeLatin1toUTF8(tr("Back"));
- next = EscapeLatin1toUTF8(tr("Next page"));
- prev = EscapeLatin1toUTF8(tr("Previous page"));
+ play = Convert2UTF(tr("Play movie"));
+ back = Convert2UTF(tr("Back"));
+ next = Convert2UTF(tr("Next page"));
+ prev = Convert2UTF(tr("Previous page"));
DrawText(stitle, 90, 52, 450, 30);
lines = DrawText(summary, 90, 120, 450, 340, 0, lines);