ALT Linux Sisyphus discussions
 help / color / mirror / Atom feed
From: Yury Aliaev <mutab0r@rambler.ru>
To: ALT Linux Sisyphus discussion list <sisyphus@lists.altlinux.org>
Subject: Re: [sisyphus] Немного рекламы: FBReader
Date: Fri, 19 May 2006 13:58:06 +0400
Message-ID: <446D96AE.5090709@rambler.ru> (raw)
In-Reply-To: <e4johf$2d9$3@sea.gmane.org>

Anton Farygin scripsit:
>>>>С диалогом выбора файлов проблема в кодировке. Так у меня в локали 1251
>>>>вылезает ошибка 
>>
>>>>(FBReader:11675): Pango-WARNING **: Invalid UTF-8 string passed to
>>>>pango_layout_set_text()
>>
>>>>на каждый файл с русским именем.
>>>
>>>а это извини проблема не этой программы.. а чего-то gtk'шного
>>
>>Ойданупрям! (C)
> 
> 
> Именно так. Я даже багу вешал на что-то по этому поводу.
> 
> Там какие-то заморочки с чарсетом для файловой системы.

Не какие-то, а вполне конкретные. В своё время Виталик Липатов составил 
подробнейшие рекомендации по локализации программ, использующих GTK+-2. 
Вот цитата оттуда:

Работа с файлами и файловыми диалогами
======================================
gchar* g_filename_from_utf8(строка,-1,NULL,NULL,NULL)
gchar* g_filename_to_utf8(строка,-1,NULL,NULL,NULL)
получаемые с помощью этих функций строки желательно
освобождать после использования с помощью g_free(указатель)

Во внутренних структурах программы рекомендуется хранить
название файла в filesystem encoding (которая получается
с помощью g_filename_from_utf8), но выдавать на редактирование
и сохранять в конфигурационные файлы - в utf8.

Возможно использование функции
g_filename_from_uri
в чём преимущества пока не знаю.

Для дублирование строк используется функция
g_strdup

Файловому диалогу передаётся название файла в filesystem
encoding.
Устанавливается название файла такой конструкцией:
gtk_file_selection_set_filename(GTK_FILE_SELECTION(opendlg),
filename);
Получается название файла так:
filename =
gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs));

Вот типичный код получения названия файла в кодировке UTF8 (взят
из dia):
const char *filename;
struct stat stat_struct;
filename =
gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs));
if (stat(filename, &stat_struct) == 0) { // File already exist
     char buffer[300];
     char *utf8filename = NULL;
     if (!g_utf8_validate(filename, -1, NULL)) {
         utf8filename = g_filename_to_utf8(filename, -1, NULL,
NULL, NULL);
         if (utf8filename == NULL) {
             message_warning(_("Some characters in the filename
are neither UTF-8 nor you local encoding"));
         }
     }
     if (utf8filename == NULL) utf8filename = g_strdup(filename);
     g_snprintf(buffer, 300,
         _("The file '%s' already exists.\n"
         "Do you want to overwrite it?"), utf8filename);
     ....
     g_free(utf8filename);
}


  reply	other threads:[~2006-05-19  9:58 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-16 11:49 Anton Farygin
2006-05-16 11:51 ` Led
2006-05-16 12:27   ` Anton Farygin
2006-05-18 14:49   ` Dmitry Marochko
2006-05-18 15:06     ` Led
2006-05-18 15:13       ` Led
2006-05-19  6:27         ` Anton Farygin
2006-05-19 10:50           ` Led
2006-05-19  6:26     ` Anton Farygin
2006-05-16 12:39 ` Dmitriy L. Kruglikov
2006-05-16 13:12   ` Anton Farygin
2006-05-18 11:09 ` Вячеслав Диконов
2006-05-18 11:15   ` Led
2006-05-18 11:20     ` Led
2006-05-18 11:18   ` Nick S. Grechukh
2006-05-18 11:21     ` Nick S. Grechukh
2006-05-18 12:27       ` Anton Farygin
2006-05-18 12:40         ` Nick S. Grechukh
2006-05-18 12:46           ` Led
2006-05-18 12:52             ` Nick S. Grechukh
2006-05-18 12:54             ` Nick S. Grechukh
2006-05-18 13:05           ` Anton Farygin
2006-05-20 11:20           ` Вячеслав Диконов
2006-05-18 11:23     ` Led
2006-05-18 12:27       ` Anton Farygin
2006-05-18 12:26   ` Anton Farygin
2006-05-19  5:28     ` Alexey I. Froloff
2006-05-19  6:28       ` Anton Farygin
2006-05-19  9:58         ` Yury Aliaev [this message]
2006-05-20 11:17     ` Вячеслав Диконов
2006-05-21  8:12       ` Michael Shigorin
2006-05-22 13:14         ` Вячеслав Диконов
2006-05-22  5:05       ` Anton Farygin
2006-05-22 13:40         ` Nick S. Grechukh
2006-05-22 13:17           ` Вячеслав Диконов
2006-05-22 13:24             ` Anton Farygin
2006-05-22 18:02               ` Nick S. Grechukh
2006-05-23  7:20                 ` Anton Farygin
2006-05-22 13:36             ` Michael Shigorin
2006-05-22  5:11       ` Afanasov Dmitry
2006-05-19  5:27   ` Alexey I. Froloff
2006-05-20 11:24     ` Вячеслав Диконов
2006-05-25 10:18 ` Artem Pastukhov
2006-05-25 10:45   ` Anton Farygin
2006-05-25 11:14     ` Dmitriy L. Kruglikov
2006-05-25 11:32       ` Led
2006-05-25 12:04         ` Anton Farygin
2006-05-25 12:11           ` Led
2006-05-25 12:14             ` Anton Farygin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=446D96AE.5090709@rambler.ru \
    --to=mutab0r@rambler.ru \
    --cc=sisyphus@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Sisyphus discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/sisyphus/0 sisyphus/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 sisyphus sisyphus/ http://lore.altlinux.org/sisyphus \
		sisyphus@altlinux.ru sisyphus@altlinux.org sisyphus@lists.altlinux.org sisyphus@lists.altlinux.ru sisyphus@lists.altlinux.com sisyphus@linuxteam.iplabs.ru sisyphus@list.linux-os.ru
	public-inbox-index sisyphus

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.sisyphus


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git