Is swscanf substring formatting ([a-z]) implemented for osx standard lib?
The following code works on windows, but not on osx.
The docs on swscanf say that:
"...some implementations of wscanf() use "A-Z" to represent the range of characters between 'A' and 'Z'. "
By some implementations, does it mean that osx doesn't implement it?
int main(int argc, const char* argv[])
{
{
wchar_t foo[] = L"bif3.zip";
wchar_t buh[10] = L"";
int val = 0;
wchar_t ext[4] = L"";
int s = swscanf(foo, L"%[a-z]%d.%ls", buh, &val, ext);
wprintf(L"wchar: %ls %d %ls\n", buh, val, ext);
}
{
char foo[] = "bif3.zip";
char buh[10] = "";
int val = 0;
char ext[4] = "";
int s = sscanf(foo, "%[a-z]%d.%s", b开发者_JAVA技巧uh, &val, ext);
printf("char: %s %d %s\n", buh, val, ext);
}
}
result:
wchar: 0
char: bif 3 zip
The man page for swscanf(3) states the following under the Bugs section:
In addition to the bugs documented in scanf(3), wscanf() does not support the “A-Z” notation for specifying character ranges with the character class conversion (‘%[’).
Feel free to file a bug report with Apple.
精彩评论