unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* locales and notmuch
@ 2019-02-21 19:11 David Bremner
  2019-02-21 19:57 ` David Bremner
  2019-06-19 13:09 ` Daniel Kahn Gillmor
  0 siblings, 2 replies; 6+ messages in thread
From: David Bremner @ 2019-02-21 19:11 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 930 bytes --]


So I've been revisiting the "user defined headers" [1] patches. I need
the <prefix> in

    $ notmuch config set index.header.<prefix> "blah"

to be unique case-insensitively, so I decided to convert them to lower
case on input. This turns out to be "fun", if we try to handle things
other than ASCII.  So one option is to just insist prefixes are ASCII.

Otherwise we could insist they are UTF-8, ignoring the locale. The
fullest generality (I think) is to first convert from the users locale
to utf8, as in the attached sample program. The gotcha is that the call
to setlocale is necessary, and can't really be local to string utility
function. So we'd have to add that to notmuch startup. We mostly ignore
locales, so I guess there shouldn't be too much side effects; otoh I
don't have much experience with locales.

So what do people think? ASCII? UTF-8? Locale sensitivitie?

[1] id:20181117140901.1870-1-david@tethera.net


[-- Attachment #2: test.c --]
[-- Type: text/x-csrc, Size: 427 bytes --]

#include <stdio.h>
#include <glib.h>
#include <gmodule.h>
#include <locale.h>

int
main (int argc, char **argv)
{
  gchar *utf8_str, *lc_str;
  GError *err = NULL;

  setlocale(LC_ALL,"");
  utf8_str = g_locale_to_utf8 ("Sn☃man",-1,NULL,NULL,&err);

  if (!utf8_str) {
    fprintf(stderr, "%s\n", err->message);
    abort();
  }

  lc_str = g_utf8_strdown (utf8_str, -1);

  printf ("%s\n", lc_str);
}

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-06-19 19:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-21 19:11 locales and notmuch David Bremner
2019-02-21 19:57 ` David Bremner
2019-02-23  0:26   ` Matt Armstrong
2019-02-23 11:43     ` David Bremner
2019-06-19 13:09 ` Daniel Kahn Gillmor
2019-06-19 19:52   ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).