LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1077|回复: 4

求助:中文编码显示问题(请尝试设置环境变量 G_BROKEN_FILENAMES)

[复制链接]
发表于 2005-8-18 15:43:25 | 显示全部楼层 |阅读模式
Gtk-Message: 文件名“TCP-IP\317\352\275\342”无法转换为 UTF-8。(请尝试设置环境变量 G_BROKEN_FILENAMES):Invalid byte sequence in conversion input
Gtk-Message: 文件名“\315\370\302\347\326\252\312\266”无法转换为 UTF-8。(请尝试设置环境变量 G_BROKEN_FILENAMES):Invalid byte sequence in conversion input
Gtk-Message: 文件名“c++\315\352\303\300\321\335\322\357\264\372\302\353.zip”无法转换为 UTF-8。(请尝试设置环境变量 G_BROKEN_FILENAMES):Invalid byte sequence in conversion input
Gtk-Message: 文件名“Linux\303\374\301\356\264\363\310\253(\320\336\270\304\260\346).chm”无法转换为 UTF-8。(请尝试设置环境变量 G_BROKEN_FILENAMES):Invalid byte sequence in conversion input
Gtk-Message: 文件名“Debian\312\271\323\303\312\326\262\341.pdf”无法转换为 UTF-8。(请尝试设置环境变量 G_BROKEN_FILENAMES):Invalid byte sequence in conversion input

当我打开acroreader的时候,出现中文名称不能转换的错误,导致无法阅读中文名称文档。
我的系统是完全支持中文的。
 楼主| 发表于 2005-8-18 16:13:22 | 显示全部楼层
export G_BROKEN_FILENAMES=1 原来这样就可以了,请问这究竟是为什么呢 ?
回复 支持 反对

使用道具 举报

发表于 2007-7-7 13:56:03 | 显示全部楼层
不晓得噢
我也是这样的问题
回复 支持 反对

使用道具 举报

发表于 2007-7-8 20:46:47 | 显示全部楼层
搜索到的
开始改用Debian,当终于把中文的显示和输入搞定,心想总算可以安心使用的时候,突然发现自己又面临一个两难的选择。

身为中国人自然要用国家标准的GB18030,所以我的Gnome的语言一定要选中文GB18030,我喜欢用Xmms听歌,当我向播放列表添加歌曲的时候发现了一个有趣的现象:在浏览文件夹的对话框中的以中文作为文件名歌曲中有一些正常,其它则在应该显示文件名的地方是一片空白。经过一番试验我发现用浏览器下载时,直接使用中文文件名保存的歌曲是可以正常显示的,而另外那些我在Nautilus文件浏览器中后改成中文文件名的则是空白。我们知道 ext2,ext3文件系统不像vfat,ntfs那样使用utf16存储文件名,而是以字节流的方式对待文件名,给它什么就用什么,不作任何转换。因此可以肯定这两种文件名是以两种编码存储的,Xmms这种GTK1的程序能够正常显示的应该是用GB编码,另外那种我想应该是GKT2使用的UTF8。为了验证,运行gedit,选择打开文件,果然Xmms不能显示的在这里正常,而Xmms正常的这里显示成/214/213/222/245这个样子,而这些数字正是汉字的GB码。不论使用哪种编码都会有问题,要么GTK1不能显示,要么GTK2显示成/xxx/xxx的样子。

有人建议我LOCALES直接设成UTF8编码算了,我试了试,也发现了一些问题:
GTK1程序在UTF8编码下不只文件名不认识,连菜单,按钮的汉字也变成乱码了。
国内ftp上的中文文件名都是GB编码,我在UTF8编码环境下用gftp不能正确浏览,听说有一个叫远程字符集的设置,不过我试了半天也没弄好。
在图形的命令行下也不能正确显示utf8编码的汉字

这样也不行,那样也不行,怎样设置都有些毛病,简直令我抓狂。

还好偶然看到了一个叫G_BROKEN_FILENAMES的环境变量,说是让GTK2使用LOCALES中的编码方式处理文件名,立即动手,在我的 .gnomerc 中加入 export G_BROKEN_FILENAMES=1
注销,选择中文GB18030,登录......
啊~~~整个世界清静了!!!


gogoliu回复:

你那是gtk 2.2时代的方法了
2.4开始应该改为
G_FILENAME_ENCODING=@local
export G_FILENAME_ENCODING
回复 支持 反对

使用道具 举报

发表于 2007-7-8 20:51:16 | 显示全部楼层
这是找到的资料
   GLib Reference Manual  

Running GLib Applications
Running GLib Applications — How to run and debug your GLib application
  

Running and debugging GLib Applications
Environment variables
GLib inspects a few of environment variables in addition to standard variables like LANG, PATH or HOME.

G_FILENAME_ENCODING.  This environment variable can be set to a comma-separated list of character set names. GLib assumes that filenames are encoded in the first character set from that list rather than in UTF-8. The special token "@locale" can be used to specify the character set for the current locale.

G_BROKEN_FILENAMES.  If this environment variable is set, GLib assumes that filenames are in the locale encoding rather than in UTF-8. G_FILENAME_ENCODING takes priority over G_BROKEN_FILENAMES.

G_MESSAGES_PREFIXED.  A list of log levels for which messages should be prefixed by the program name and PID of the application. The default is to prefix everything except G_LOG_LEVEL_MESSAGE and G_LOG_LEVEL_INFO.

G_DEBUG.  If GLib has been configured with --enable-debug=yes, this variable can be set to a list of debug options, which cause GLib to print out different types of debugging information.

fatal_warnings Causes GLib to abort the program at the first call to g_warning() or g_critical(). This option is special in that it doesn't require GLib to be configured with debugging support.

fatal_criticals Causes GLib to abort the program at the first call to g_critical(). This option is special in that it doesn't require GLib to be configured with debugging support.

gc-friendly Newly allocated memory that isn't directly initialized, as well as memory being freed will be reset to 0. The point here is to allow memory checkers and similar programs that use bohem GC alike algorithms to produce more accurate results. This option is special in that it doesn't require GLib to be configured with debugging support.

resident-modules All modules loaded by GModule will be made resident. This can be useful for tracking memory leaks in modules which are later unloaded; but it can also hide bugs where code is accessed after the module would have normally been unloaded. This option is special in that it doesn't require GLib to be configured with debugging support.

bind-now-modules All modules loaded by GModule will bind their symbols at load time, even when the code uses %G_MODULE_BIND_LAZY. This option is special in that it doesn't require GLib to be configured with debugging support.



G_SLICE.  This environment variable allows reconfiguration of the GSlice memory allocator.

always-malloc This will cause all slices allocated through g_slice_alloc() and released by g_slice_free1() to be actually allocated via direct calls to g_malloc() and g_free(). This is most useful for memory checkers and similar programs that use Bohem GC alike algorithms to produce more accurate results. It can also be in conjunction with debugging features of the system's malloc implementation such as glibc's MALLOC_CHECK_=2 to debug erroneous slice allocation code, allthough debug-blocks usually is a better suited debugging tool.

debug-blocks Using this option (present since GLib-2.13) engages extra code which performs sanity checks on the released memory slices. Invalid slice adresses or slice sizes will be reported and lead to a program halt. This option should only be used in debugging scenarios, because it significantly degrades GSlice performance. Extra per slice memory is requied to do the necessary bookeeping, and multi-thread scalability is given up to perform global slice validation. This option is mostly useful in scenarios where program crashes are encountered while GSlice is in use, but crashes cannot be reproduced with G_SLICE=always-malloc. A potential cause for such a situation that will be caught by G_SLICE=debug-blocks is e.g.:

                    void *slist = g_slist_alloc(); /* void* gives up type-safety */
                    g_list_free (slist);           /* corruption: sizeof (GSList) != sizeof (GList) */
                  




G_RANDOM_VERSION.  If this environment variable is set to '2.0', the outdated pseudo-random number seeding and generation algorithms from GLib-2.0 are used instead of the new better ones. Use the GLib-2.0 algorithms only if you have sequences of numbers generated with Glib-2.0 that you need to reproduce exactly.

LIBCHARSET_ALIAS_DIR.  Allows to specify a nonstandard location for the charset.aliases file that is used by the character set conversion routines. The default location is the libdir specified at compilation time.

G_WIN32_PRETEND_WIN9X.  Setting this variable to any value forces g_win32_get_windows_version() to return a version code for Windows 9x. This is mainly an internal debugging aid for GTK+ and GLib developers, to be able to check the code paths for Windows 9x.


--------------------------------------------------------------------------------

Locale
A number of interfaces in GLib depend on the current locale in which an application is running. Therefore, most GLib-using applications should call setlocale (LC_ALL, "") to set up the current locale.


--------------------------------------------------------------------------------

Traps and traces
Some code portions contain trap variables that can be set during debugging time if GLib has been configured with --enable-debug=yes. Such traps lead to immediate code halts to examine the current program state and backtrace.

Currently, the following trap variables exist:

static volatile gulong g_trap_free_size;
static volatile gulong g_trap_realloc_size;
static volatile gulong g_trap_malloc_size;

If set to a size > 0, g_free(), g_realloc() and g_malloc() will be intercepted if the size matches the size of the corresponding memory block. This will only work with g_mem_set_vtable (glib_mem_profiler_table) upon startup though, because memory profiling is required to match on the memory block sizes.

Note that many modern debuggers support conditional breakpoints, which achieve pretty much the same. E.g. in gdb, you can do

break g_malloc
condition 1 n_bytes == 20

to break only on g_malloc() calls where the size of the allocated memory block is 20.


--------------------------------------------------------------------------------

Memory statistics
g_mem_profile() will output a summary g_malloc() memory usage, if memory profiling has been enabled by calling g_mem_set_vtable (glib_mem_profiler_table) upon startup.

If GLib has been configured with --enable-debug=yes, then g_slice_debug_tree_statistics() can be called in a debugger to output details about the memory usage of the slice allocator.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表