cyrillic suport in MOC

i would be thankful to the MOC's developers, if they'll try to include cyrillic support for the correct indication of russian-named tags, (it's boring to see ######-##### in cyrillic tags). i think it would be a great gift for the russian users of MOC! maybe there are some patches tor the cyrillic support in MOC? so if it's not difficult for you, please show me some links to it...

.....with much respect, XATRIX

it's already done
check "ID3v1TagsEncoding" in config file. (Set it to WINDOWS-1251)

where is that config file....seems i have no one.. exactly the path and the filename please

The example config file comes with MOC sources (config.example), you can use it to create your ~/.moc/config

--
Damian Pietras - MOC developer

hmmm...i have no such a file there... :0 can you post it ? or email me xatrix@skyinet.com.ua

You don't have config.example? Download moc-2.4.1.tar.bz2 from here and it's there. If you talk about ~/.moc/config, you need to create it, just cp config.example ~/.moc/config.

--
Damian Pietras - MOC developer

sorry i should post it here...

"i have a "moc 2.4.0 Build: Sep 9 2006 18:56:34" from gentoo-linux ports...ok, i'll download the source tarball form here and extract the config file to my root dir"

It's not your root directory, but your home directory, like /home/user/.moc/config

--
Damian Pietras - MOC developer

I have no problem with utf-8 azbuck (russian characters) in flac tags.

I had the same problem (both cyrillic filenames and tags were shown as ####) due to wide character support missing from ncurses. Installing correct ncurses version and recompiling mocp solved it (for sake of completeness - FreeBSD specific problem, I think. Ships with old ncurses in base system. I've installed devel/ncurses and just reinstalled audio/moc port)

i have a "moc 2.4.0 Build: Sep 9 2006 18:56:34" from gentoo-linux ports...ok, i'll download the source tarball form here and extract the config file to my root dir

What about cyrillic in directory name? Does moc use librcc for directories names now? It don't work for me.

It doesn't, it's a known bug.

--
Damian Pietras - MOC developer

Using unstable ncurses from gentoo portage and the latest MOC, but get #### on the koi8-r filesystem..Tags are in UTF8 and look great.. Maybe it is possible to fix this problem?

Is MOC linked with ncursesw or ncurses? You can check it by running ldd /path/to/mocp

--
Damian Pietras - MOC developer

Now with ncurses..I tried both =)

You see, tags(in UTF8) are displayed well :)
On the filesystem I use KOI8-R encoding, locale ru_RU.KOI8-R, if the file has UTF8 tags it's name is taken from the tags and displayed well, but the directories and files with cyrillic names without tags are displayed with ####### :(

MOC don't understand UTF8 tags in ID3v1 but in ID3v2 it's ok. Very old problem for MOC. And don't understand cp1251 tags then i use options ID3v1TagsEncoding and/or UseRCC. System locale UTF8. In KOI8-R locale users say me - ID3v1TagsEncoding and UseRCC works.

Is MOC linked with ncursesw or ncurses?

ncursesw! ncurses don't like UTF-8 :)

Vorb, I use patch:
<br /> Index: decoder_plugins/mp3/mp3.c<br /> ===================================================================<br /> --- decoder_plugins/mp3/mp3.c (revision 1982)<br /> +++ decoder_plugins/mp3/mp3.c (working copy)<br /> @@ -156,7 +156,7 @@</p> <p> /* Workaround for ID3 tags v1/v1.1 where the encoding<br /> * is latin1. */<br /> - if (id3_tag_options(tag, 0, 0) &amp; ID3_TAG_OPTION_ID3V1) {<br /> + if (0 &amp;& id3_tag_options(tag, 0, 0) &amp; ID3_TAG_OPTION_ID3V1) {<br /> char *t;</p> <p> comm = (char *)id3_ucs4_latin1duplicate (ucs4);<br />

But it's not real solution.

I have all tags in UTF, I have problem ONLY with filesystem! )))

gg..I installed librcc and now everything's ok)) I was sure that librcc was installed.... Thx 4 answers and sorry)

see new topic - http://moc.daper.net/node/282 - Russian MOC

just solved this problem for me

I've already written about it here - http://moc.daper.net/node/228.
Everything is good with filenames when I'm using patched for librcc support version of moc. But title of filebrowser still contains #####...

I also have this problem and I have one more. When I enter the catalog named cyrillic symbols - everything's ok, but when I return to the prev catalog - selection appears on the top, not on the catalog I leaved.. If the directory is in English - everything's ok..

Cyrillic symbols in filenames and tags shows as "##########".
I tried all ways witch used in this topic, but nothing happend.
OS: Mandriva 2009.1, codepage UTF-8, tags in UTF-8 (ID3v2 and Vorbis Comment only). MOC v2.4.4

P.S. Execuse me for my poor english.
-------------------------------------------------------------
Кириллица в именах файлов и тэгах отображается решётками. Перепробовал всё, что тут написано, но ничего не помогает.
ОС: Mandriva 2009.1, кодировка UTF-8, тэги (ID3v2 и Vorbis Comment) в UTF-8. MOC v2.4.4

You need have "libncursesw-devel" installed before compiling mocp.

Added options:

  • FileNamesIconv (bool): enables charset conversion for filenames. This option fixes "###" for non-UTF filenames. Local encoding used in conversion depends on locale.
  • EnforceTagsEncoding (bool): apply ID3v1TagsEncoding to all id3 tags.


diff -c -r moc-2.4.4/decoder_plugins/mp3/mp3.c moc-2.4.4.1/decoder_plugins/mp3/mp3.c
*** moc-2.4.4/decoder_plugins/mp3/mp3.c 2007-02-11 15:40:13.000000000 +0300
--- moc-2.4.4.1/decoder_plugins/mp3/mp3.c 2009-05-25 10:01:20.000000000 +0400
***************
*** 154,160 ****

/* Workaround for ID3 tags v1/v1.1 where the encoding
* is latin1. */
! if (id3_tag_options(tag, 0, 0) & ID3_TAG_OPTION_ID3V1) {
char *t;

comm = (char *)id3_ucs4_latin1duplicate (ucs4);
--- 154,162 ----

/* Workaround for ID3 tags v1/v1.1 where the encoding
* is latin1. */
! if ((id3_tag_options(tag, 0, 0) & ID3_TAG_OPTION_ID3V1)
! || (options_get_int ("EnforceTagsEncoding")))
! {
char *t;

comm = (char *)id3_ucs4_latin1duplicate (ucs4);
diff -c -r moc-2.4.4/files.c moc-2.4.4.1/files.c
*** moc-2.4.4/files.c 2008-03-11 18:56:18.000000000 +0300
--- moc-2.4.4.1/files.c 2009-05-25 00:38:53.000000000 +0400
***************
*** 42,51 ****
--- 42,53 ----
#include "files.h"
#include "playlist_file.h"
#include "log.h"
+ #include "utf8.h"

#define FILE_LIST_INIT_SIZE 64
#define READ_LINE_INIT_SIZE 256

+
/* Is the string an URL? */
inline int is_url (const char *str)
{
***************
*** 104,109 ****
--- 106,118 ----
*dot = 0;
}

+ if (options_get_int ("FileNamesIconv"))
+ {
+ char *old_title = file;
+ file = files_iconv_str (file);
+ free (old_title);
+ }
+
plist_set_title_file (plist, num, file);
free (file);
}
***************
*** 232,237 ****
--- 241,248 ----
buf[--len] = 0;
}

+
+
/* Read selected tags for a file into tags structure (or create it if NULL).
* If some tags are already present, don't read them.
* If present_tags is NULL, allocate new tags. */
diff -c -r moc-2.4.4/interface_elements.c moc-2.4.4.1/interface_elements.c
*** moc-2.4.4/interface_elements.c 2008-06-29 13:56:13.000000000 +0400
--- moc-2.4.4.1/interface_elements.c 2009-05-25 10:27:51.000000000 +0400
***************
*** 60,65 ****
--- 60,66 ----
#define STARTUP_MESSAGE "Welcome to " PACKAGE_STRING "!"
#define HISTORY_SIZE 50

+
/* TODO: removing/adding a char to the entry may increase width of the text
* by more than one column. */

***************
*** 910,916 ****
char *old_title = title;

title = xstrdup (slash + 1);
! free (old_title);
}
}
}
--- 911,917 ----
char *old_title = title;

title = xstrdup (slash + 1);
! free (old_title);
}
}
}
***************
*** 930,937 ****
char *title;
const char *type_name;

! title = make_menu_title (item->title, item->title == item->title_tags,
! full_paths);
added = menu_add (menu, title, plist_file_type(plist, num), item->file);
free (title);

--- 931,939 ----
char *title;
const char *type_name;

!
! title = make_menu_title (item->title, item->title == item->title_tags,
! full_paths);
added = menu_add (menu, title, plist_file_type(plist, num), item->file);
free (title);

***************
*** 1003,1011 ****
for (i = 0; i < dirs->num; i++) {
char title[PATH_MAX];

! strcpy (title, strrchr(dirs->items[i], '/') + 1);
! strcat (title, "/");
!
added = menu_add (m->menu.list.main, title, F_DIR,
dirs->items[i]);
menu_item_set_attr_normal (added,
--- 1005,1025 ----
for (i = 0; i < dirs->num; i++) {
char title[PATH_MAX];

! if (options_get_int ("FileNamesIconv"))
! {
! char *conv_title = files_iconv_str (
! strrchr(dirs->items[i], '/') + 1);
!
! strcpy (title, conv_title);
! strcat (title, "/");
!
! free (conv_title);
! }
! else
! {
! strcpy (title, strrchr(dirs->items[i], '/') + 1);
! strcat (title, "/");
! }
added = menu_add (m->menu.list.main, title, F_DIR,
dirs->items[i]);
menu_item_set_attr_normal (added,
***************
*** 3140,3150 ****
/* Set the title for the directory menu. */
void iface_set_title (const enum iface_menu menu, const char *title)
{
assert (title != NULL);

! main_win_set_title (&main_win,
! menu == IFACE_MENU_DIR ? MENU_DIR : MENU_PLAYLIST,
! title);
iface_refresh_screen ();
}

--- 3154,3179 ----
/* Set the title for the directory menu. */
void iface_set_title (const enum iface_menu menu, const char *title)
{
+
assert (title != NULL);

! if (options_get_int ("FileNamesIconv"))
! {
! char *conv_title = NULL;
! conv_title = files_iconv_str (title);
!
! main_win_set_title (&main_win,
! menu == IFACE_MENU_DIR ? MENU_DIR : MENU_PLAYLIST,
! conv_title);
!
! free (conv_title);
! }
! else
! {
! main_win_set_title (&main_win,
! menu == IFACE_MENU_DIR ? MENU_DIR : MENU_PLAYLIST,
! title);
! }
iface_refresh_screen ();
}

diff -c -r moc-2.4.4/options.c moc-2.4.4.1/options.c
*** moc-2.4.4/options.c 2007-05-22 22:24:34.000000000 +0400
--- moc-2.4.4.1/options.c 2009-05-25 09:59:07.000000000 +0400
***************
*** 213,222 ****
--- 213,224 ----
option_add_int ("CanStartInPlaylist", 1);
option_add_int ("UseCursorSelection", 0);
option_add_str ("ID3v1TagsEncoding", "WINDOWS-1250");
+ option_add_int ("EnforceTagsEncoding", 0);
option_add_int ("UseRCC", 1);
option_add_int ("SetXtermTitle", 1);
option_add_int ("PlaylistFullPaths", 1);
option_add_int ("Allow24bitOutput", 0);
+ option_add_int ("FileNamesIconv", 0);
}

/* Return 1 if a parameter to an integer option is valid. */
***************
*** 243,249 ****
|| !strcasecmp(name, "SetXtermTitle")
|| !strcasecmp(name, "PlaylistFullPaths")
|| !strcasecmp(name, "Allow24bitOutput")
! ) {
if (!(val == 1 || val == 0))
return 0;
}
--- 245,253 ----
|| !strcasecmp(name, "SetXtermTitle")
|| !strcasecmp(name, "PlaylistFullPaths")
|| !strcasecmp(name, "Allow24bitOutput")
! || !strcasecmp(name, "FileNamesIconv")
! || !strcasecmp(name, "EnforceTagsEncoding")
! ) {
if (!(val == 1 || val == 0))
return 0;
}
***************
*** 294,300 ****
&& strcasecmp(val, "IfAvailable"))
return 0;
}
! else if (!strcmp(name, "ResampleMethod")) {
if (strcasecmp(val, "SincBestQuality")
&& strcasecmp(val, "SincMediumQuality")
&& strcasecmp(val, "SincFastest")
--- 298,304 ----
&& strcasecmp(val, "IfAvailable"))
return 0;
}
! else if (!strcmp(name, "ResampleMethod")) {
if (strcasecmp(val, "SincBestQuality")
&& strcasecmp(val, "SincMediumQuality")
&& strcasecmp(val, "SincFastest")
***************
*** 308,315 ****

static int is_deprecated_option (const char *name)
{
! if (!strcmp(name, "TagsIconv")
! || !strcmp(name, "FileNamesIconv"))
return 1;

return 0;
--- 312,318 ----

static int is_deprecated_option (const char *name)
{
! if (!strcmp(name, "TagsIconv"))
return 1;

return 0;
diff -c -r moc-2.4.4/playlist.c moc-2.4.4.1/playlist.c
*** moc-2.4.4/playlist.c 2008-12-21 13:27:41.000000000 +0300
--- moc-2.4.4.1/playlist.c 2009-05-25 10:32:14.000000000 +0400
***************
*** 633,638 ****
--- 633,640 ----
plist->items[num].title_tags = xstrdup (title);
}

+
+
/* Set file title of an item. */
void plist_set_title_file (struct plist *plist, const int num,
const char *title)
***************
*** 641,647 ****

if (plist->items[num].title_file)
free (plist->items[num].title_file);
! plist->items[num].title_file = xstrdup (title);
}

/* Set file for an item. */
--- 643,649 ----

if (plist->items[num].title_file)
free (plist->items[num].title_file);
! plist->items[num].title_file = xstrdup (title);
}

/* Set file for an item. */
diff -c -r moc-2.4.4/utf8.c moc-2.4.4.1/utf8.c
*** moc-2.4.4/utf8.c 2007-02-11 15:40:13.000000000 +0300
--- moc-2.4.4.1/utf8.c 2009-05-25 00:40:58.000000000 +0400
***************
*** 19,24 ****
--- 19,25 ----
#endif

#include
+
#ifdef HAVE_ICONV_H
# include
#endif
***************
*** 43,54 ****
--- 44,58 ----

#include "common.h"
#include "log.h"
+ #include "options.h"
#include "utf8.h"

static char *terminal_charset = NULL;
static int using_utf8 = 0;

static iconv_t iconv_desc = (iconv_t)(-1);
+ static iconv_t files_iconv_desc = (iconv_t)(-1);
+

/* Return a malloc()ed string converted using iconv().
* if for_file_name is not 0, uses the conversion defined for file names.
***************
*** 105,110 ****
--- 109,119 ----
return converted;
}

+ char *files_iconv_str (const char *str)
+ {
+ return iconv_str (files_iconv_desc, str);
+ }
+
int xwaddstr (WINDOW *win, const char *str)
{
int res;
***************
*** 320,325 ****
--- 329,339 ----
if (iconv_desc == (iconv_t)(-1))
logit ("iconv_open() failed: %s", strerror(errno));
}
+
+ if (options_get_int ("FileNamesIconv"))
+ {
+ files_iconv_desc = iconv_open ("UTF-8", "");
+ }
}

void utf8_cleanup ()
diff -c -r moc-2.4.4/utf8.h moc-2.4.4.1/utf8.h
*** moc-2.4.4/utf8.h 2007-02-11 15:40:13.000000000 +0300
--- moc-2.4.4.1/utf8.h 2009-05-24 23:12:36.000000000 +0400
***************
*** 35,39 ****
--- 35,40 ----
char *xstrtail (const char *str, const int len);

char *iconv_str (const iconv_t desc, const char *str);
+ char *files_iconv_str (const char *str);

#endif

Please send me your patch as an attachment by email, it's hard to read it here. I'd like to include it in MOC.

Warning: do not use this patch, its buggy.

There is at least one bug. Also, i slightly changed behaviour of "EnforceTagsEncoding" option to avoid conversion of UTF encoded tags.

If somebody wants to get current version, ask me by mail (ya-nayk at yandex dot ru).

daper: I will send you the final version of the patch by mail, when it will be ready (in a week or two, i think).

Recent version adds the following options:

  • FileNamesIconv (bool)
    Enables conversion of filenames from local encoding to UTF8.
  • EnforceTagsEncoding (bool)
    When this option is set, player assumes, that if encoding of id3v2 is set to ISO-8859-1, then it is actually ID3v1TagsEncoding, and applies appropriate conversion.
  • NonUTFXterm (bool)
    This option enables conversion of xterm title from UTF8 to local encoding.
  • I have already sent this patch to daper.