Skip to content

Commit

Permalink
looks like there's no C.UTF-8 locale on BSD ...
Browse files Browse the repository at this point in the history
  • Loading branch information
aG0aep6G committed Apr 22, 2018
1 parent a908a0b commit e00ca2f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions std/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -3435,13 +3435,16 @@ void main()

version (Posix)
{
version (FreeBSD) enum utf8locale = "en_US.UTF-8";
else enum utf8locale = "C.UTF-8";

const char* oldCt = () @trusted {
return setlocale(LC_CTYPE, null);
}();
const char[] newCt = () @trusted {
return setlocale(LC_CTYPE, "C.UTF-8").fromStringz;
return setlocale(LC_CTYPE, utf8locale).fromStringz;
} ();
assert(newCt == "C.UTF-8");
assert(newCt == utf8locale);
scope(exit) () @trusted { setlocale(LC_CTYPE, oldCt); } ();
}

Expand Down

0 comments on commit e00ca2f

Please sign in to comment.