diff --git a/HISTORY b/HISTORY index 56dd122..ef95c45 100755 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,6 @@ +Apr. 29 2016 +Fixed a loading bug when importing a UTF8 file + Apr. 26 2016 Added an invalid operation usage error when met an unexpected expression diff --git a/core/my_basic.c b/core/my_basic.c index a4029dd..32abab4 100755 --- a/core/my_basic.c +++ b/core/my_basic.c @@ -4279,10 +4279,19 @@ static char* _load_file(mb_interpreter_t* s, const char* f, const char* prefix) } buf = (char*)mb_malloc((size_t)(l + 1)); mb_assert(buf); - if(prefix) { + if(prefix) memcpy(buf, prefix, i); - } fread(buf + i, 1, l, fp); +#ifdef MB_ENABLE_UNICODE + do { + char* off = buf + i; + int b = mb_uu_getbom(&off); + if(b) { + memmove(buf + i, buf + i + b, l - b - i); + buf[l - b] = _ZERO_CHAR; + } + } while(0); +#endif /* MB_ENABLE_UNICODE */ fclose(fp); buf[l] = _ZERO_CHAR; } diff --git a/output/my_basic.exe b/output/my_basic.exe index 30f65e5..68d4d21 100755 Binary files a/output/my_basic.exe and b/output/my_basic.exe differ