[darcs-users] escapes and locales support for darcs 1.0

Tommy Pettersson ptp at lysator.liu.se
Sat Aug 14 12:30:53 UTC 2004


In the previous discussion on how to support locales in darcs
(following my bug report on "blue text") it think the consensus
was to wait with this until after 1.0.

I'm sorry to say I liked darcs better without the escape
bug fix that followed.  Before that I didn't have to read
whatsnew:s like:

  {
  hunk ./file 17
  +j\x75st a fingered exam\x70le t\x6f sh\x6fw what it is like
  }


  There is a very simple way to sport the limited but common
set of 8-bit locales, such as 8859-1, for natively encoded
repositories.  The ctypes (like isPrint) is an existing and
working framework for this.

  {
  hunk ./Printer.lhs 247
  -          escape1 c | isAscii c && (isPrint c || isSpace c) = Nothing
  +          escape1 c | (isPrint c || isSpace c) = Nothing
  }

It will not work, and possibly be bad, with other than these
locales.  So I wanted to make it run-time conditional with an
environment variable: DARC_USE_ISPRINT or DARCS_8BIT_LOCALE
or such, the same way DARCS_SLOPPY_LOCKS works.  But I don't
know how to code that in Haskell.  getEnv returns IO and
escape is pure functional and I want a Bool.

  ...
      escape1 c | (isAscii || trust_locale) && (isPrint c || isSpace c) = Nothing
  
  trust_locale = ??? getEnv "DARCS_8BIT_LOCALE" ???

I guess this is the wrong way, that instead trust_locale must
be set (with <- ?) at the right place and time in an invoking
IO-ing function.  But then it will be out of scope???


  Could this way of "limited locale support" be accepted into
darcs 1.0 if I can produce a working patch after some time and
Haskell doc reading?  It won't hurt anyone who doesn't set the
environment variable.  It will help at least me, and possibly
more (one or two ;-) of us who wait-and-see about this utf8.
It can be totally dropped when fancy locale support is ready.


-- 
Tommy Pettersson <ptp at lysator.liu.se>





More information about the darcs-users mailing list