#include <locale.h>
#include <langinfo.h>
#include <caml/mlvalues.h>
#include <caml/memory.h>
#include <caml/alloc.h>
value caml_setlocale(value locale){
CAMLparam1 (locale);
setlocale (LC_ALL, String_val (locale));
CAMLreturn (Val_int (0));
}
value get_enc(value unit){
CAMLparam1 (unit);
char *s;
s = nl_langinfo (CODESET);
if (s == NULL) s = "INVARIANT";
CAMLreturn (copy_string (s));
}
value get_locale(value unit){
CAMLparam1 (unit);
char *s;
s = setlocale (LC_COLLATE, NULL);
if (s == NULL) s = "";
CAMLreturn (copy_string (s));
}
syntax highlighted by Code2HTML, v. 0.9.1