Re: Can someone please comment on this short program

On Tue, December 13, 2005 10:56 am, Matthias Kaeppler said:
> Christophe Fergeau wrote:
>>>I haven't yet found a way to make an Uri work when pointing to a file
>>>which name contains umlauts, please help.
>> Maybe that's an encoding issue, ie täst is encoded in UTF-8 on the disk
>> while you are trying to read täst encoded in ISO8859-1 from your
>> program ?
> Hm, yes I think you're right. I have tried executing the code like this
> now:
>      {
> 	UriPtr uri = Uri::create(get_uri_from_local_path(home_dir));
> 	uri = uri->append_file_name(Glib::filename_to_utf8(filename));
> 	std::cout << "Uri: " << uri->to_string() << " | exists: ";
> 	std::cout << std::boolalpha << uri->uri_exists() << std::endl;
>      }
> matthias:testing$ G_FILENAME_ENCODING=ISO-8859-1 ./a.out
> Uri: file:///home/matthias | exists: true
> Uri: file:///home/matthias/t%C3%A4st | exists: true
> Uri: file:///home/matthias/t%25E4st | exists: false
> The problem seems to be that Emacs is encoding the name "täst" in
> ISO-8859-1 instead of UTF-8. This would at least explain the problem
> with this test case, where the string was hardwired into the code...

Some tips for encoding charsets troubles:
 - You can quickly know what charset a file is with "$ file -i some_file.c"
 - You can quickly convert a file from one charset to another with gnu

[nelson sitec07 ~]$ file -i kitar.txt
kitar.txt: text/plain; charset=iso-8859-1
[nelson sitec07 ~]$ recode iso-8859-1..UTF8 kitar.txt
[nelson sitec07 ~]$ file -i kitar.txt
kitar.txt: text/plain; charset=utf-8
[nelson sitec07 ~]$

 Here[2] is a script that converts recursively the files in a directory
from iso-8859-1 to utf8. But better you get your editor to work with utf8
or try another editor (gvim?).


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]