mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 18:42:41 +01:00
NumberParser::parseHex[64](): allow 0x/0X prefix
This commit is contained in:
@@ -84,7 +84,9 @@ unsigned NumberParser::parseHex(const std::string& s)
|
||||
|
||||
bool NumberParser::tryParseHex(const std::string& s, unsigned& value)
|
||||
{
|
||||
return strToInt(s.c_str(), value, NUM_BASE_HEX);
|
||||
int offset = 0;
|
||||
if (s.size() > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) offset = 2;
|
||||
return strToInt(s.c_str() + offset, value, NUM_BASE_HEX);
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +153,9 @@ UInt64 NumberParser::parseHex64(const std::string& s)
|
||||
|
||||
bool NumberParser::tryParseHex64(const std::string& s, UInt64& value)
|
||||
{
|
||||
return strToInt(s.c_str(), value, NUM_BASE_HEX);
|
||||
int offset = 0;
|
||||
if (s.size() > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) offset = 2;
|
||||
return strToInt(s.c_str() + offset, value, NUM_BASE_HEX);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user