[xmonad] spawn functions are not unicode safe

Gwern Branwen gwern0 at gmail.com
Wed Jan 14 19:23:30 EST 2009

Hash: SHA512

On Wed, Jan 14, 2009 at 6:58 PM, Sean Escriva  wrote:
> On Wed, Jan 14, 2009 at 06:12:07PM -0500, Gwern Branwen wrote:
>> Hash: SHA512
>> On Wed, Jan 14, 2009 at 5:46 PM, Khudyakov Alexey  wrote:
>> > Hello.
>> >
>> > There is problem with `spawn' function as well with *spawn family from
>> > XMonad.Util.Run. They mangle unicode symbols which are passed to them. This
>> > is because they make use of `executeFile' which silently truncate
each letter
>> > to one byte.
>> >
>> > Simplest workaround is to use utf8-string package. It would work only on
>> > systems with UTF8 locales but now they are majority I hope.
>> >
>> >> import Codec.Binary.UTF8.String
>> >> -- | Unicode safe spawn
>> >> spawnU :: MonadIO m => String -> m ()
>> >> spawnU = spawn . encodeString
>> >
>> > The same possible for all *spawn functions. I think it's worth to include
>> > unicodified versions to XMonadContrib but not sure is there anyone who need
>> > such functionality
>> I think it's worth including such functionality (especially as we
>> already depend on utf8-string in XMC). I often run Wikipedia & Google
>> searches on terms which include accents and other such UTFy things,
>> and it's a little tiresome fixing the search. Likely they are coming
>> pre-mangled by X, but if the spawn functions are also guilty then this
>> would at least be a step further.
>> That said, it's also worth asking where this should be done. Do we
>> leave XMonad core alone, and provide spawnU in XMC (and rewrite the
>> ~53 XMC calls to call spawnU)?
> whats the benefit to maintaining non unicode spawn behavior? is it
> needlessly complex to have a spawnA and spawnU and then the actual
> spawn function determines the more appropriate function to use based
> on the string itself?

How would it determine that? I don't know that Data.Char.isLatin1 would suffice.

(Incidentally, I added an encodeString to safeSpawn and unsafeSpawn in
XMonad.Util.Run, and my searches seem to be passing through

- --
Version: GnuPG v1.4.9 (GNU/Linux)


More information about the xmonad mailing list