[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    ASCII files (was Re: A great idea! (?))
From:       Stefan van den Oord <s.m.vandenoord () student ! utwente ! nl>
Date:       1999-05-25 9:57:50
[Download RAW message or body]

>> [snip]
>> But still I have plain text files that
>> are not recognized by KDE (it asks me what application to open the
>> file with). The `file' command says: "International language text".
>kfm doesn't use the 'file' command. It uses a similar mechanism
>(borrowing code from it), but not EXACTLY the same thing, since
>we don't want a long string that describes the mimetype - instead we want 
>the mimetype itself. "text/plain" for instance. Have a look at 
>kmimemagic.cpp (in KDE-1.1.x, in kdebase/kfm) or kmimemagic.cc in kdelibs/kio.
>
>> But, looking at the /usr/share/magic, I wonder if this type is
>> recognized due to some magic, because I can't find the entry that
>> could lead to "International language text".
>Look at kdelibs/kio/magic, not /usr/share/magic


I have been poking around in the source, and found the problem. I
have a dir with five text files, of which only 2 are recognized as
text files. I tested my hypothesis, and it appeared to be correct.

The problem is that the text files that are not recognized have high
ascii in the first 1024 (kdebase/kfm/kmimemagic.cpp:55: #define
HOWMANY 1024). For example, an 'e' with an accent grave. In the same
file, at line 1853-, I read:

    for (i = 0; i < nbytes; i++) {
        if (!isascii(*(buf + i)))
            return 0;   /* not all ascii */
    }

The problem, I think, is that the system call isascii() does not check
for high ascii. I think this means the check must be extended,
something like:

        if ( !isascii(*(buf + i)) && !ishighascii(*(buf + i)))

I don't mean this litterally, but to show what I mean.

Stefan

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic