@@ -46,6 +46,11 @@ using namespace sttp;
4646const datetime_t DateTimeEpoch (date(1400 , 1 , 1 ), TimeSpan(0 , 0 , 0 ));
4747const auto DateTimeTicksPerSecond = TimeSpan::ticks_per_second();
4848
49+ inline int GetRadix (const string& value)
50+ {
51+ return StartsWith (value, " 0x" ) ? 16 : 10 ;
52+ }
53+
4954string PreparseTimestamp (const string& timestamp, TimeSpan& utcOffset)
5055{
5156 // 2018-03-14T19:23:11.665-04:00
@@ -402,7 +407,7 @@ bool sttp::TryParseUInt16(const string& value, uint16_t& result, const uint16_t
402407{
403408 try
404409 {
405- const auto conversion = stoul (value);
410+ const auto conversion = stoul (value, nullptr , GetRadix (value) );
406411
407412 if (conversion > UInt16::MaxValue)
408413 {
@@ -424,7 +429,7 @@ bool sttp::TryParseInt32(const string& value, int32_t& result, const int32_t def
424429{
425430 try
426431 {
427- result = stoi (value);
432+ result = stoi (value, nullptr , GetRadix (value) );
428433 return true ;
429434 }
430435 catch (...)
@@ -438,7 +443,7 @@ bool sttp::TryParseUInt32(const string& value, uint32_t& result, const uint32_t
438443{
439444 try
440445 {
441- result = stoul (value);
446+ result = stoul (value, nullptr , GetRadix (value) );
442447 return true ;
443448 }
444449 catch (...)
@@ -452,7 +457,7 @@ bool sttp::TryParseInt64(const string& value, int64_t& result, const int64_t def
452457{
453458 try
454459 {
455- result = stoll (value);
460+ result = stoll (value, nullptr , GetRadix (value) );
456461 return true ;
457462 }
458463 catch (...)
0 commit comments