UTF-8 library

Alastair Reid alastair@reid-consulting-uk.ltd.uk
05 Aug 2002 14:11:17 +0100


> I would very much like to hear some comments, also on the use of
> unsafePerformIO with locale-dependent functions (gettext is of
> course locale-dependent).

As long as nothing calls setlocale, there's not much problem: things
will work consistently within a program run though they may vary
between runs.

If you wanted to be able to change the locale at runtime or you want
to follow the lead of System.getArgs, you can either:

1) Put locale dependent functions in the IO monad.

or

2) Make the locale a parameter (either explicit or implicit) of the
   functions and have the locale dependent functions change locale as
   needed.  Only call setlocale if the locale has changed since the
   last time you called a locale-dependent function.

   Nice clean design but you'd better be sure to wrap all
   locale-dependent functions (including other C functions which
   invoke locale-dependent functions) - it'd be murder to debug it if
   you mess up.   

-- 
Alastair Reid                 alastair@reid-consulting-uk.ltd.uk  
Reid Consulting (UK) Limited  http://www.reid-consulting-uk.ltd.uk/alastair/