[Toybox] [PATCH] main.c: fix UTF-8 on macOS.

enh enh at google.com
Tue Jan 5 14:16:29 PST 2021


from bionic's xlocale.h:

/**
 * @file xlocale.h
 * @brief `locale_t` definition.
 *
 * Most users will want `<locale.h>` instead. `<xlocale.h>` is used by the C
 * library itself to export the `locale_t` type without exporting the
 * `<locale.h>` functions in other headers that export locale-sensitive
 * functions (such as `<string.h>`).
 */

except macOS insists on keeping newlocale(3) there, despite POSIX.

new patch attached, which moves the #include to portability.h and adds a
comment...



On Sat, Dec 19, 2020 at 2:30 AM Rob Landley <rob at landley.net> wrote:

> On 12/14/20 11:13 PM, enh wrote:
> > On Mon, Dec 14, 2020 at 8:54 PM Rob Landley wrote:
> >
> > >    On 12/14/20 7:33 PM, enh via Toybox wrote:
> > >    > Unfortunately neither "C.UTF-8" nor "UTF-8" works on *both*
> OSes...
> > >
> > >    Tempted to newlocale() and uselocale() to edit utf8 support into
> "C" myself, but
> > >    that's even LESS likely to work on macos, isn't it?
> > >
> > >    Rob
> >> actually, the attached patch (on top of the one you already committed)
> doing
> > exactly that does work for me on macOS. (untested on Linux though!)
>
> What's xlocale.h? It's not in posix and musl hasn't got it.
>
> Rob
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20210105/794eb587/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-main.c-construct-a-combination-locale-to-add-UTF-8.patch
Type: application/octet-stream
Size: 2226 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20210105/794eb587/attachment-0002.obj>


More information about the Toybox mailing list