WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: GTK2 and GTK3 cannot handle Unicode characters in file names  (Read 6296 times)

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: GTK2 and GTK3 cannot handle Unicode characters in file names
« Reply #15 on: December 12, 2019, 09:11:07 AM »
Rich - Good to know. Thanks.

Two quick questions:

1. Can anyone confirm whether glib2.tcz has been stripped of "unicode tables" in the interest of keeping the extension small?

2. In case these tables are absent from glib2.tcz, how do I obtain them? Can I just copy the relevant files from a different distro?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11703
Re: GTK2 and GTK3 cannot handle Unicode characters in file names
« Reply #16 on: December 12, 2019, 09:22:32 AM »
Hi Hi GNUser
A helpful GNOME/GTK user (developer?) suggested this issue may be due to unicode data tables missing from glib2. He recommended that I try installing glib2-locale.tcz: https://discourse.gnome.org/t/support-for-unicode-characters-in-gtk2-3-file-selection-box/2338/5

Alas, glib2-locale.tcz is not available in the Pure64 repository :( I put in an extension request.
Maybe he meant  glibc_gconv.tcz  or  glibc_i18n_locale.tcz (which also contains character maps)?

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: GTK2 and GTK3 cannot handle Unicode characters in file names
« Reply #17 on: December 12, 2019, 09:49:13 AM »
glibc_gconv.tcz has been loaded all along. Loading glibc_i18n_locale.tcz makes no difference :(

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: GTK2 and GTK3 cannot handle Unicode characters in file names
« Reply #18 on: December 12, 2019, 10:29:50 AM »
In case this helps, here is a simple way I can trigger the bug: I launch my web browser (iridium, which uses GTK3), go to duckduckgo.com, press Control+p to print, choose "Save as PDF", then click "Save".

The page name (DuckDuckGo – Privacy, simplified.) is automatically selected as the filename for the PDF and the dash (between DuckDuckGo and Privacy) triggers the bug. I cannot print to PDF until I delete the dash in the filename (replacing it with a hyphen, for example).
« Last Edit: December 12, 2019, 10:50:57 AM by GNUser »

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: GTK2 and GTK3 cannot handle Unicode characters in file names
« Reply #19 on: December 12, 2019, 11:47:36 AM »
Solved! This does the trick:

Code: [Select]
$ export G_FILENAME_ENCODING=UTF-8
Make it permanent by adding it to ~/.profile

I found the solution when I stumbled upon this:
https://www.gnu.org/software/guile-gnome/docs/gtk/html/GtkFileChooser.html#GtkFileChooser
« Last Edit: December 12, 2019, 11:56:53 AM by GNUser »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11049
Re: GTK2 and GTK3 cannot handle Unicode characters in file names
« Reply #20 on: December 12, 2019, 01:23:14 PM »
That reminded me, my LFS box has this in bashrc:
Quote
export G_FILENAME_ENCODING=@locale

However glib docs claim it defaults to utf-8, which is weird in your case.
The only barriers that can stop you are the ones you create yourself.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: GTK2 and GTK3 cannot handle Unicode characters in file names
« Reply #21 on: December 12, 2019, 01:37:16 PM »
If I don't specify a value for the variable, I find that it's set to iso8859-1:

Code: [Select]
bruno@box:~$ echo $G_FILENAME_ENCODING
iso8859-1

Maybe glib does default to utf-8--I found this in /etc/profile:

Code: [Select]
# Screen display for X and encoding for GTK+ apps.
#
G_FILENAME_ENCODING=iso8859-1

Boy, did it cause me a world of hurt. Maybe something similar to what LFS does would be a better way to go than hardcoding a default encoding?
« Last Edit: December 12, 2019, 01:40:28 PM by GNUser »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11049
Re: GTK2 and GTK3 cannot handle Unicode characters in file names
« Reply #22 on: December 12, 2019, 01:45:15 PM »
I think that's for best compatibility with fat32 etc. Trying to create utf-8 names on fat32 would either fail or be incompatible with Windows IIRC. By default, TC does not have locales installed, it's the "C" default which is ASCII, which would prevent the @locale from being useful.
The only barriers that can stop you are the ones you create yourself.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: GTK2 and GTK3 cannot handle Unicode characters in file names
« Reply #23 on: December 12, 2019, 01:46:01 PM »
If I don't specify an encoding in ~/.profile and comment-out the relevant line in /etc/profile (and backup the changes), the variable doesn't have a value after a reboot:

Code: [Select]
bruno@box:~$ echo $G_FILENAME_ENCODING

bruno@box:~$

Everything works as expected in this scenario, so glib must indeed be defaulting to utf-8.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: GTK2 and GTK3 cannot handle Unicode characters in file names
« Reply #24 on: December 12, 2019, 01:49:04 PM »
Perhaps getlocale.tcz could give the user a hint about this environmental variable potentially being a pitfall? It could prevent some pain.
« Last Edit: December 12, 2019, 01:59:48 PM by GNUser »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11049
Re: GTK2 and GTK3 cannot handle Unicode characters in file names
« Reply #25 on: December 13, 2019, 04:38:34 AM »
Note added to getlocale.tcz.info (10.x x86 and x86_64).
The only barriers that can stop you are the ones you create yourself.