1 #include <wchar.h>
2 #include <locale.h>
3 #include "libc.h"
4
5 /* collate only by code points */
6 // ANDROID: Was __wcsxfrm_l in Musl
wcsxfrm_l(wchar_t * restrict dest,const wchar_t * restrict src,size_t n,locale_t loc)7 size_t wcsxfrm_l(wchar_t *restrict dest, const wchar_t *restrict src, size_t n, locale_t loc)
8 {
9 size_t l = wcslen(src);
10 if (l < n) {
11 wmemcpy(dest, src, l+1);
12 } else if (n) {
13 wmemcpy(dest, src, n-1);
14 dest[n-1] = 0;
15 }
16 return l;
17 }
18
wcsxfrm(wchar_t * restrict dest,const wchar_t * restrict src,size_t n)19 size_t wcsxfrm(wchar_t *restrict dest, const wchar_t *restrict src, size_t n)
20 {
21 return wcsxfrm_l(dest, src, n, 0);
22 }
23
24 weak_alias(__wcsxfrm_l, wcsxfrm_l);
25