Thanks for the responses. I tried what I could, but it still doesn't work. I wrote some code to test if I can open and close a file. The C code works but the Chicken code doesn't.
---------- test.c
----------
#include <stdio.h>
#include <wchar.h>
// this file needs to be saved with explicit BOM (byte order mark) otherwise it won't work
int main()
{
FILE* fileHandle = _wfopen(L"c:\\temp\\íűőúöüóéá.txt", L"r");
printf("File has been opened at: %p\n", fileHandle);
printf("Closing file\n");
fclose(fileHandle);
return 0;
}
---------- test.scm
----------
(import (chicken foreign))
(foreign-declare "#include <stdio.h>")
(foreign-declare "#include <wchar.h>")
(define chicken_wfopen
(foreign-lambda (c-pointer "FILE") "_wfopen" (c-pointer "wchar_t") (c-pointer "wchar_t")))
(define chicken_fclose
(foreign-lambda int "fclose" (c-pointer "FILE")))
(let ([file-handle (chicken_wfopen "c:\\temp\\íűőúöüóéá.txt" "r")])
(print "File has been opened at: "
(number->string file-handle))
(print "Closing file.")
(chicken_fclose file-handle))
The Chicken code fails with the error message: Error: unbound variable:
It doesn't say the name of the variable, and it returns the error code 70.
Note that in C the string needs to be prefixed with an L to make it wide character. In Chicken I don't know how to do that.
Does anybody have a clue which variable is unbound?