Locale & wide character strangeness

David Adam zanchey at ucc.gu.uwa.edu.au
Wed May 25 15:58:12 PDT 2016


Hello,

I help work on fish-shell, an alternative command-line shell. Recently 
we've had some reports of strange behaviour on newer versions of DragonFly 
BSD, which as far as I can tell come down to unusual behaviours of wide 
character functions in the UTF-8 locale.

As an example, here is a minimal testcase:

--- min.cpp:
#include <locale.h>
#include <stdio.h>
#include <wchar.h>

int main() {
	setlocale(LC_ALL, "");
	fwprintf(stdout, L"%ls\n", L"written to stdout");
	fwprintf(stderr, L"%ls\n", L"written to stderr");
	return 0;
}
---

Run as `c++ min.cpp -o min; env LANG=C ./min; env LANG=en_US.UTF-8 ./min`

On FreeBSD, OS X and Linux this outputs:
written to stdout
written to stderr
written to stdout
written to stderr

On DragonFly BSD v4.5.0.1036.g151571-DEVELOPMENT, however:
written to stdout
written to stderr
written to stdout

What happened to my second message under the UTF-8 locale?

I think there are other problems too, but I haven't been able to isolate 
them to proper testcases - there is some discussion at 
https://github.com/fish-shell/fish-shell/issues/3050 .

Any ideas?

Many thanks,

David Adam
zanchey at ucc.gu.uwa.edu.au



More information about the Users mailing list