Print this page
2964 need POSIX 2008 locale object support
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Approved by: TBD
@@ -1,6 +1,7 @@
/*
+ * Copyright 2013 Garrett D'Amore <garrett@damore.org>
* Copyright 2010 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2002-2004 Tim J. Robbins.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,18 +28,26 @@
#include "lint.h"
#include <limits.h>
#include <stdio.h>
#include <wchar.h>
+#include <locale.h>
+#include <xlocale.h>
#include "mblocal.h"
int
-wctob(wint_t c)
+wctob_l(wint_t c, locale_t loc)
{
static const mbstate_t initial = { 0 };
mbstate_t mbs = initial;
char buf[MB_LEN_MAX];
- if (c == WEOF || __wcrtomb(buf, c, &mbs) != 1)
+ if (c == WEOF || wcrtomb_l(buf, c, &mbs, loc) != 1)
return (EOF);
return ((unsigned char)*buf);
+}
+
+int
+wctob(wint_t c)
+{
+ return (wctob_l(c, uselocale(NULL)));
}