guile-user
[Top][All Lists]
Advanced

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

Re: charset conversion


From: Christian Mauduit
Subject: Re: charset conversion
Date: Fri, 10 Feb 2006 21:30:16 +0100
User-agent: Mozilla Thunderbird 1.0.7 (X11/20051018)

Hi,

William Xu a écrit :
>>I did some bits for my charting program, converting to and from utf8
>>using the libc iconv() stuff (plus some ascii-only fallbacks).  You
>>could also run the iconv command-line program from within guile if you
>>don't want C code, and only have a few bits to convert.
> 
> 
> Hmm, yeah, a scheme wrapper around iconv() works okay. Thanks.

BTW (not extactly your question, but it's related) in my program (
http://www.gnu.org/software/liquidwar6/ ) I use a wrapper over gettext (
see src/funcs.c for code snippets). The idea is to handle charset
conversions through gettext. I also use a quirk & dirty shell script:

-----8<---------------------------
#!/bin/sh

SCRIPT_DIR=../src/script
C_FILE=../src/scriptpo.c

find $SCRIPT_DIR -type f -a -name "*.scm" \
    | xargs sed "s/^.*( *_  *\\(\\\".*\\\"\\) *).*\$/_(\1)\; \\/\\/
extracted by scriptpo-update.sh/g" \
    | grep scriptpo-update.sh \
    > $C_FILE
-----8<---------------------------

to create a .c file which can then be processed by gettext tools. The
idea is to create a dummy C file with contents like:

_("my string");      // extracted by scriptpo-update.sh

whenever there's a line in a scheme file with a construct of the form

(_ "my string")

This file is never compiled but gettext tools parse it, and this way you
can use a po-style translation system for you Guile strings. This is
lightweight code but it provides me with a translating framework which
is "scheme-enabled" and very similar to what usually happens in C.

It's easy to use: whenever you want something to be translated, and not
bother about charsets, simply replace:

"your string"

with the form:

(_ "your string")

Period.

Have a nice day,

Christian.

-- 
Christian Mauduit <address@hidden>     __/\__ ___
                                        \~/ ~/(`_ \   ___
http://www.ufoot.org/                   /_o _\   \ \_/ _ \_
http://www.ufoot.org/ufoot.pub (GnuPG)    \/      \___/ \__)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]