The function fwscanf() return value is wrong incase of invalid input character.
int ret = fwscanf(fptr, L"j%s", buf);
The above call should return ZERO for matching failure, however it currently returns EOF.
The fscanf() function behaves correctly. Comparing the source of both functions confirms the return is value is wrong for fwscanf().