[xmlsec] non us-ascii filenames in user locale

Roumen Petrov xmlsec at roumenpetrov.info
Wed Jun 23 02:22:15 PDT 2004

Igor Zlatkovic wrote:

> On 22.06.2004 15:08, Roumen Petrov wrote:
>> Igor Zlatkovic wrote:
>>> I hope you are not proposing to put this into xmlsec?
>> =-O What to put into xmlsec ?
> Somehing that converts, or tries to convert, an Unicode string into a 
> non-Unicode one 900 times whenever a file must be accessed.
NO-NO-NO :-) ;-)

> That is what the talk is about, or did I miss something?

I just check whats happen. This test show that when we know only unicode 
name of a file we cannot convert it to non-unicode.
Technically UTF-8 string "modèle.txt" (see attached file test.c - new 
version) can be converted to 374 charset, but only 88 names are valid.

> Ciao,
> Igor

-------------- next part --------------
#include <iconv.h>
#include <stdio.h>
#include <unistd.h>

/* iconv(2.2.5) --list:
The following list contain all the coded character sets known.  This does
not necessarily mean that all combinations of these names can be used for
the FROM and TO command line parameters.  One coded character set can be
listed with several different names (aliases).
const char*
iconv_list[] = {

main(int argc, char *argv[]) {
    const char unistr[] = "modèle.txt";
    const char **charset;
    int count_found = 0;
    int count_locale = 0;

    for (charset = iconv_list; *charset; charset++) {
        iconv_t cd;

        cd = iconv_open(*charset, "UTF-8");
        if (cd == (iconv_t)(-1)) continue;

            char buf[256];

            /*const*/ char *inbuf;
            size_t      inlen;
            char       *outbuf;
            size_t      outlen;

            inbuf = unistr;
            inlen = strlen(inbuf);

            outbuf = buf;
            outlen = sizeof(buf);
            memset(outbuf, 0, outlen);

            iconv(cd, &inbuf, &inlen, &outbuf, &outlen);
            if (inlen == 0) {
                int found = (access(buf, F_OK) == 0);

                if (found) count_found++;
                fprintf(stderr, " \"%s\"-%s:%s\n", *charset, (found ? "yes": "no"), buf);

    fprintf(stderr, "counter=%d/%d/%d\n", count_found, count_locale, (sizeof(iconv_list) / sizeof(*iconv_list) - 1));
    exit (0);
    return (0);

More information about the xmlsec mailing list