| 560 | |
| 561 | #ifdef _WIN32 |
| 562 | static wchar_t * ggml_mbstowcs(const char * mbs) { |
| 563 | int wlen = MultiByteToWideChar(CP_UTF8, 0, mbs, -1, NULL, 0); |
| 564 | if (!wlen) { |
| 565 | errno = EINVAL; |
| 566 | return NULL; |
| 567 | } |
| 568 | |
| 569 | wchar_t * wbuf = GGML_MALLOC(wlen * sizeof(wchar_t)); |
| 570 | wlen = MultiByteToWideChar(CP_UTF8, 0, mbs, -1, wbuf, wlen); |
| 571 | if (!wlen) { |
| 572 | GGML_FREE(wbuf); |
| 573 | errno = EINVAL; |
| 574 | return NULL; |
| 575 | } |
| 576 | |
| 577 | return wbuf; |
| 578 | } |
| 579 | #endif |
| 580 | |
| 581 | FILE * ggml_fopen(const char * fname, const char * mode) { |