I cannot open a lot of files
Brought to you by:
ajk265
In some files (a lot of for me) I cannot open them (woh! my english!!)
The error is:
(openldev:13770): Gtk-CRITICAL **: gtk_text_buffer_emit_insert: assertion `g_utf8_validate (text, len, NULL)' failed
I'm Spanish and perhaps I have inserted in this files some no UTF-8 characters like ñ or á é í...
I attach an example file.
Regards,
chuchi
Logged In: YES
user_id=1679342
Originator: YES
The critical is printed when you call:
114 gtk_text_buffer_set_text (GTK_TEXT_BUFFER (tab->buffer), text, -1);
The backtrace is:
#0 file_tab_new (file=0x84b4a8c "/home/chuchi/desarrollo/sources/gedit/plugins/gedituv/gedituv-conf-manager.c") at openldev-file-tab.cc:115
#1 0xb7299b2b in file_manager_add_tab (manager=0x80c0808, file=0x84b4a8c "/home/chuchi/desarrollo/sources/gedit/plugins/gedituv/gedituv-conf-manager.c",
env=0x80b3950) at openldev-file-manager.cc:273
#2 0xb727d5ac in openldev_open_file (openldev=0x80b3000, file=0x8479910 "/home/chuchi/desarrollo/sources/gedit/plugins/gedituv/gedituv-conf-manager.c")
at openldev-file.cc:296
#3 0x0804b1e9 in handle_selection_file_browser (openldev=0x80b3000, treeview=0x80c8068) at main.cc:323
#4 0x0804b322 in on_button_press_event_file_browser (widget=0x80c8068, event=0x8461560, openldev=0x80b3000) at main.cc:347
#5 0xb78936b0 in _gtk_marshal_BOOLEAN__BOXED () from /usr/lib/libgtk-x11-2.0.so.0
#6 0xb735162b in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#7 0xb7362103 in ?? () from /usr/lib/libgobject-2.0.so.0
#8 0x08461880 in ?? ()
#9 0xbfba95a0 in ?? ()
#10 0x00000002 in ?? ()
#11 0xbfba967c in ?? ()
#12 0xbfba958c in ?? ()
#13 0xb7380670 in ?? () from /usr/lib/libgobject-2.0.so.0
#14 0xb7125be0 in ?? () from /lib/tls/i686/cmov/libpthread.so.0
#15 0xbfba95d0 in ?? ()
#16 0xb7380670 in ?? () from /usr/lib/libgobject-2.0.so.0
#17 0xbfba9584 in ?? ()
#18 0xbfba9608 in ?? ()
#19 0xbfba95b4 in ?? ()
#20 0x080c8068 in ?? ()
#21 0x00000000 in ?? ()
Logged In: YES
user_id=1679342
Originator: YES
The problem is the codification. My Linux is ISO-8859-15 and openldev only support UTF-8. When openldev read the file, we need transform from locale to utf-8. I attach you a diff file.
Regards
File Added: utf8_error.diff
Logged In: YES
user_id=1679342
Originator: YES
We need do g_locale_from_utf8 when we write the file content to disk
Logged In: YES
user_id=1679342
Originator: YES
Another diff file to save correctly in the user locale
File Added: save_to_locale.diff
Logged In: YES
user_id=795740
Originator: NO
This is partially fixed in current SVN.
Right now you can only open files encoded UTF-8 or the same as the users locale. We should add a list of possible encoding and step through the list to try and automatically detect the file encoding if it is not UTF-8 or the users locale.
We also should be savings the original file encoding, so when saving the file, we can save it in the correct encoding. Right now the file is either saved UTF-8 or as the users locale. The error handling also could be improved.
Logged In: YES
user_id=1679342
Originator: YES
You can take a look at gedit. It save and open files correctly. I think it use locale_to_utf8 and locale_from_utf8
Logged In: YES
user_id=1679342
Originator: YES
This is a conversation in IRC. I think this is the better way:
<chuchiperriman> i'm spanish and i use locale: ISO-8859-15
when I read a file from disk ans I use it with GtkTextView....
what I may do?
locale_to_utf8??
<datallah> chuchiperriman: probably. The problem is that the files don't have to be in your locale.
<datallah> I mean, the file name, of course.
<chuchiperriman> ups...
<doublep> chuchiperriman: you want to convert file _contents_ or _name_?
<datallah> If you know what the file contents are encoded in, you can use an explicit conversion (g_convert())
<chuchiperriman> right, I could have a file in my system in ISO but the file use UTF-8?
<doublep> sure
<chuchiperriman> I may check the file encoding before do nothing...
How I can do it?
<doublep> no way
<chuchiperriman> Ups
<doublep> no robust way
for instance, first validate it as utf-8
if it is valid, assume it is indeed utf-8...
else try to convert from system locale
else ask user
like that
<-- xan has quit (Ex-Chat)
<chuchiperriman> I understand...
<doublep> if i fire up gedit it defaults to "auto detect" encoding of new files
<chuchiperriman> I will take a look at gedit
<doublep> so, since you can still opt to specify encoding manually, auto detection is not guaranteed to be correct
<chuchiperriman> ok
<doublep> s/new files/newly open files/
<chuchiperriman> you are very amiable
thank you very much!!!
Logged In: YES
user_id=1679342
Originator: YES
Hi again, I'm tried subversion code and not solve my problem. I don't know why... When I insert the patch that I send you, works fine but I don't understand,I may try it again...
I have a file in ISO-8859, my system is in ISO-8859-15 and openldev cannot open it. I attach the file
Regards,
Chuchi
File Added: gtk-snippet.c
Logged In: YES
user_id=795740
Originator: NO
Delete your old SVN tree and check out the checkout the current code again. Your old tree probably did not update correctly with the changes you had made before.