Update wcwidth implementation for Windows and add a binding library
This commit is contained in:
parent
2b87655157
commit
da2f4802c5
32
src/modules/module_wcwidth.c
Normal file
32
src/modules/module_wcwidth.c
Normal file
@ -0,0 +1,32 @@
|
||||
#include <kuroko/vm.h>
|
||||
#include <kuroko/util.h>
|
||||
|
||||
#include <wchar.h>
|
||||
#include <locale.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
extern int wcwidth(wchar_t c);
|
||||
#else
|
||||
static
|
||||
#include "../wcwidth._h"
|
||||
#endif
|
||||
|
||||
KRK_FUNC(wcwidth,{
|
||||
FUNCTION_TAKES_EXACTLY(1);
|
||||
CHECK_ARG(0,int,krk_integer_type,codepoint);
|
||||
return INTEGER_VAL(wcwidth(codepoint));
|
||||
})
|
||||
|
||||
KrkValue krk_module_onload_wcwidth(void) {
|
||||
KrkInstance * module = krk_newInstance(vm.baseClasses->moduleClass);
|
||||
krk_push(OBJECT_VAL(module));
|
||||
KRK_DOC(module, "Character widths.");
|
||||
BIND_FUNC(module, wcwidth);
|
||||
|
||||
#ifndef _WIN32
|
||||
setlocale(LC_ALL, "");
|
||||
#endif
|
||||
|
||||
return krk_pop();
|
||||
}
|
||||
|
1430
src/wcwidth._h
1430
src/wcwidth._h
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user