StringToFloat overload. Returns true if the entire string is a valid, finite float.
This commit is contained in:
@@ -1509,6 +1509,15 @@ float StringToFloat( const RString &sString )
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool StringToFloat( const RString &sString, float &fOut )
|
||||
{
|
||||
char *endPtr;
|
||||
|
||||
fOut = strtof( sString, &endPtr );
|
||||
return sString.size() && *endPtr == '\0' && isfinite( fOut );
|
||||
}
|
||||
|
||||
|
||||
const wchar_t INVALID_CHAR = 0xFFFD; /* U+FFFD REPLACEMENT CHARACTER */
|
||||
|
||||
wstring RStringToWstring( const RString &s )
|
||||
|
||||
@@ -310,6 +310,7 @@ void MakeLower( char *p, size_t iLen );
|
||||
void MakeUpper( wchar_t *p, size_t iLen );
|
||||
void MakeLower( wchar_t *p, size_t iLen );
|
||||
float StringToFloat( const RString &sString );
|
||||
bool StringToFloat( const RString &sString, float &fOut );
|
||||
|
||||
RString WStringToRString( const wstring &sString );
|
||||
RString WcharToUTF8( wchar_t c );
|
||||
|
||||
Reference in New Issue
Block a user