annotate gui/app/cfg-old.c @ 35926:eab9c3e8a565

Support mixed filename encodings. This also supports falsely stated filename encodings. Part 2 of 3: file selector path list. In order for the filenames to look readable, it's necessary to set G_FILENAME_ENCODING (for non-UTF8 or mixed encodings only).
author ib
date Tue, 19 Mar 2013 17:22:48 +0000
parents bd3e9d8df038
children 277882d42938
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35871
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
1 /*
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
2 * This file is part of MPlayer.
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
3 *
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
7 * (at your option) any later version.
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
8 *
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
12 * GNU General Public License for more details.
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
13 *
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License along
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
17 */
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
18
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
19 /**
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
20 * @file
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
21 * @brief Translation of old settings or old configure options
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
22 */
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
23
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
24 /**
35920
bd3e9d8df038 Revise doxygen comment.
ib
parents: 35872
diff changeset
25 * @brief Convert a filename into the original byte sequence
bd3e9d8df038 Revise doxygen comment.
ib
parents: 35872
diff changeset
26 * according to the encoding specified in G_FILENAME_ENCODING,
bd3e9d8df038 Revise doxygen comment.
ib
parents: 35872
diff changeset
27 * if it's currently in UTF-8.
35871
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
28 *
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
29 * @param fname filename
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
30 *
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
31 * @return converted filename
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
32 */
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
33 static const gchar *cfg_old_filename_from_utf8(const gchar *fname)
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
34 {
35926
eab9c3e8a565 Support mixed filename encodings.
ib
parents: 35920
diff changeset
35 #if defined(CFG_OLD_PLAYLIST) || defined(CFG_OLD_FILESELECT)
35871
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
36 static gchar *name;
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
37
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
38 if (g_utf8_validate(fname, -1, NULL)) {
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
39 free(name);
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
40 name = g_filename_from_utf8(fname, -1, NULL, NULL, NULL);
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
41
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
42 return name;
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
43 }
35872
93ab56bda68a Utilize new cfg_old_filename_from_utf8() in playlist code.
ib
parents: 35871
diff changeset
44 #endif
35871
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
45 return fname;
8f49b68dd955 Add a function converting into locale encoding.
ib
parents:
diff changeset
46 }
35872
93ab56bda68a Utilize new cfg_old_filename_from_utf8() in playlist code.
ib
parents: 35871
diff changeset
47
35926
eab9c3e8a565 Support mixed filename encodings.
ib
parents: 35920
diff changeset
48 #undef CFG_OLD_FILESELECT
35872
93ab56bda68a Utilize new cfg_old_filename_from_utf8() in playlist code.
ib
parents: 35871
diff changeset
49 #undef CFG_OLD_PLAYLIST