Skip to content

Instantly share code, notes, and snippets.

@jblachly
Created August 31, 2016 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jblachly/0372fb6cb71c09c09fc7ec4be7fcba82 to your computer and use it in GitHub Desktop.
Save jblachly/0372fb6cb71c09c09fc7ec4be7fcba82 to your computer and use it in GitHub Desktop.
jsbmbp13:/tmp$ uname -a
Darwin jsbmbp13.local 15.6.0 Darwin Kernel Version 15.6.0: Thu Jun 23 18:25:34 PDT 2016; root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64
jsbmbp13:/tmp$ locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL=
jsbmbp13:/tmp$ cat wcsncasecmp.cpp
#include<wchar.h>
#include<stdio.h>
#include<stdlib.h>
int main(void) {
wchar_t s1[1024];
wchar_t s2[1024];
size_t n = 3;
int e = mbstowcs(s1, "SET", 3);
e = mbstowcs(s2, "SET", 3);
int ret = wcsncasecmp(s1, s2, n);
printf("ret: %i\n", ret);
return 0;
}
jsbmbp13:/tmp$ ./a.out
ret: 0
===
james@smartos-dev:/tmp % uname -a 16-08-31 2:02:29
SunOS smartos-dev 5.11 joyent_20160731T153326Z i86pc i386 i86pc Solaris
james@smartos-dev:/tmp % locale 16-08-31 2:04:54
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_ALL=
james@smartos-dev:/tmp % cat wcsncasecmp.cpp 16-08-31 2:04:25
#include<wchar.h>
#include<stdio.h>
#include<stdlib.h>
int main(void) {
wchar_t s1[1024];
wchar_t s2[1024];
size_t n = 3;
int e = mbstowcs(s1, "SET", 3);
e = mbstowcs(s2, "SET", 3);
int ret = wcsncasecmp(s1, s2, n);
printf("ret: %i\n", ret);
return 0;
}
james@smartos-dev:/tmp % ./a.out 16-08-31 2:04:32
ret: 641
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment