 +      free(newtext);
 +      break;
 +    default:
-+      fprintf(stderr, "ERROR: encoding %d not handled in conversion!\n", encoding);
++      fprintf(stderr, _("ERROR: encoding %d not handled in conversion!\n"), encoding);
 +      break;
 +  }
 +}
-+
-+oe_lyrics *load_lyrics(const char *filename, oe_encoding encoding)
-+{
-+#ifdef HAVE_KATE
++#endif
++
++#ifdef HAVE_KATE
++static int add_lyrics(oe_lyrics *lyrics, char *text, oe_encoding encoding,double t0,double t1)
++{
++  size_t len;
++  int ret;
++
++  convert_subtitle_to_utf8(encoding,(unsigned char*)text);
++  len = strlen(text);
++  lyrics->lyrics = (oe_lyrics_item*)realloc(lyrics->lyrics, (lyrics->count+1)*sizeof(oe_lyrics_item));
++  if (!lyrics->lyrics) {
++    fprintf(stderr, _("Out of memory\n"));
++    return -1;
++  }
++  ret=kate_text_validate(kate_utf8,text,len+1);
++  if (ret<0) {
++    fprintf(stderr,_("WARNING: subtitle %s is not valid utf-8\n"),text);
++  }
++  else {
++    /* kill off trailing \n characters */
++    while (len>0) {
++      if (text[len-1]=='\n') text[--len]=0; else break;
++    }
++    lyrics->lyrics[lyrics->count].text = (char*)malloc(len+1);
++    memcpy(lyrics->lyrics[lyrics->count].text, text, len+1);
++    lyrics->lyrics[lyrics->count].len = len;
++    lyrics->lyrics[lyrics->count].t0 = t0;
++    lyrics->lyrics[lyrics->count].t1 = t1;
++    lyrics->count++;
++  }
++  return 0;
++}
++#endif
++
++#ifdef HAVE_KATE
++static oe_lyrics *load_srt_lyrics(FILE *f, oe_encoding encoding)
++{
 +    enum { need_id, need_timing, need_text };
 +    int need = need_id;
 +    int last_seen_id=0;
 +    int ret;
 +    int id;
 +    static char text[4096];
++    static char str[4096];
 +    int h0,m0,s0,ms0,h1,m1,s1,ms1;
 +    double t0=0.0;
 +    double t1=0.0;
-+    static char str[4096];
-+    int warned=0;
 +    oe_lyrics *lyrics;
-+
-+    lyrics = NULL;
-+    FILE *f = fopen(filename, "r");
-+    if (!f) {
-+        fprintf(stderr,"WARNING - Failed to open lyrics file %s (%s)\n", filename, strerror(errno));
-+        return NULL;
-+    }
 +
 +    lyrics=(oe_lyrics*)malloc(sizeof(oe_lyrics));
 +    if (!lyrics) return NULL;
 +    lyrics->count = 0;
 +    lyrics->lyrics = NULL;
-+
-+    /* first, check for a BOM */
-+    ret=fread(str,1,3,f);
-+    if (ret<3 || memcmp(str,"\xef\xbb\xbf",3)) {
-+      /* No BOM, rewind */
-+      fseek(f,0,SEEK_SET);
-+    }
 +
 +    fgets2(str,sizeof(str),f);
 +    while (!feof(f)) {

+    if (ptr) *ptr='\n';
+    return ret;
+}
+
+static double hmsms2s(int h,int m,int s,int ms)
+{
+    return h*3600+m*60+s+ms/1000.0;
+}
+
+/* very simple implementation when no iconv */
+static void convert_subtitle_to_utf8(oe_encoding encoding,unsigned char *text)
+{

+#endif
+
--- /dev/null	2008-04-05 19:24:09.000000000 +0100
+++ oggenc/lyrics.c	2008-07-14 21:27:38.000000000 +0100
@@ -0,0 +1,358 @@
+/* OggEnc
+ **
+ ** This program is distributed under the GNU General Public License, version 2.
