emscripten-core / emscripten-core/emscripten
swscanf returns EOF (-1) if input string contains characters > 0x7F
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
### swscanf returns EOF (-1) if input string contains characters > 0x7F
```
#include
#include
int main(int argc, char* argv[])
{
// works fine with the dollar
wchar_t test[] = L"60S$";
int val1 = -1;
int ret1 = swscanf(test,L"%d",&val1);
// doesn't work if we replace the dollar with the pound
test[3] = 0x00A3;
int val2 = -1;
int ret2 = swscanf(test,L"%d",&val2);
printf("ret1=%d, val1=%d, ret2=%d, val2=%d\n",
ret1,val1,ret2,val2);
return ret2;
}
```
Output from above program is:
`ret1=1, val1=60, ret2=-1, val2=-1`
Expected:
`ret1=1, val1=60, ret2=1, val2=60`
Interestingly, `swscanf` should not read currency character at all, it should terminate on 'S' character as it does not match `%d` format.
Also, I've tested `wcstol` family of functions, they seam to work, It's strange swscanf makes no use of them.
Contributor guide
Assessment
This issue has not been assessed yet.