libcdio-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libcdio-devel] How tolerant to be towards CD-TEXT character set mis


From: Thomas Schmitt
Subject: Re: [Libcdio-devel] How tolerant to be towards CD-TEXT character set mislabeling ?
Date: Mon, 29 Apr 2019 11:55:48 +0200

Hi,

i wrote:
> > But i could not find any character set where a-accent-grave is 0x88.

Serge Pouliquen wrote:
> an other option is human mistake

I assume the text creator at some stage had a look at it.

I wonder how popular music players display the text.
(Is there something which Leon and i did not see when we explored the
 known published info about CD-TEXT ?)


> If I was able to read that my first cd was declaring ascii encoding, and
> not displaying line with accent, I may not have filled a bug report...

But that would have been bad for science and enlightenment. :))


A cheap solution would be a cdio_debug() message in lib/driver/cdtext.c
which reports the found character set code, the related name, and the
effectively chosen character set.
Like (untested, not even compiled):

         switch (blocksize.charcode){
           case CDTEXT_CHARCODE_ISO_8859_1:
-            /* default */
             charset = (char *) "ISO-8859-1";
             break;
           case CDTEXT_CHARCODE_ASCII:
             charset = (char *) "ISO-8859-1";
             break;
           case CDTEXT_CHARCODE_SHIFT_JIS:
             charset = (char *) "SHIFT_JIS";
             break;
+          default:
+            /* Do not let charset pass here as NULL */
+            cdio_warn("CD-TEXT: Unknown character set code %u.\n",
+                      (unsigned int) blocksize.charcode);
+           charset = (char *) "ISO-8859-1";
+       }
+
+       cdio_debug("CD-TEXT character set: code=%u , name=%s , chosen=%s\n",
+                  (unsigned int) blocksize.charcode,
+                  blocksize.charcode == 0 ? "ISO-8859-1" :
+                  blocksize.charcode == 1 ? "ASCII" :
+                  blocksize.charcode == 0x80 ? "SHIFT_JIS" :
+                  "",
+                  charset);

But i always had difficulties to get cdio_debug() messages displayed.
Try whether you have more luck.

The new switch-default case is heavily advisable, because of

  char          *charset = NULL;

Currently libcdio will suffer SIGSEGV if the character set code on CD
is not one of the three defined numbers.


A solid solution would be to give cd-info.c access to this property.

The definitions of structs cdtext_s and cdtext_block_s in
  lib/driver/cdtext_private.h
show no preparations for recording the character set name or code.

One would have to add a uint8_t element to cdtext_s, which is the
implementation of type cdtext_t, which is used by e.g. src/cd-info.c.

In lib/driver/cdtext.c, directly where we do our experiments about "ASCII",
"ISO-8859-1", and "CP1252", the character set code byte would be recorded

         /* determine encoding */
+        p_cdtext->the_new_uint8_t_element = blocksize.charcode;
         switch (blocksize.charcode){
           case CDTEXT_CHARCODE_ISO_8859_1:
-            /* default */
             charset = (char *) "ISO-8859-1";
             break;
           case CDTEXT_CHARCODE_ASCII:
             charset = (char *) "ASCII";
             break;
            case CDTEXT_CHARCODE_SHIFT_JIS:
              charset = (char *) "SHIFT_JIS";
              break;
+          default:
+            /* Do not let charset pass here as NULL */
+            cdio_warn("CD-TEXT: Unknown character set code %u.\n",
+                      (unsigned int) blocksize.charcode);
+           charset = (char *) "ISO-8859-1";
+       }

Finally a new API call would be needed so that scr/cd-info.c et.al.
can obtain the byte and the related character set namei from its
cdtext_t object.
Documentation, testing, ... and everything i forgot now ...


Have a nice day :)

Thomas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]