diff --git a/Foundation/src/Format.cpp b/Foundation/src/Format.cpp index 2a34a265a..8077568e6 100644 --- a/Foundation/src/Format.cpp +++ b/Foundation/src/Format.cpp @@ -226,8 +226,16 @@ namespace } break; case 's': - str << RefAnyCast(*itVal++); + { + const Any& val = *itVal++; + if (val.type() == typeid(char*)) + str << AnyCast(val); + else if (val.type() == typeid(const char*)) + str << AnyCast(val); + else + str << RefAnyCast(val); break; + } case 'z': str << AnyCast(*itVal++); break; diff --git a/Foundation/testsuite/src/FormatTest.cpp b/Foundation/testsuite/src/FormatTest.cpp index b1afa7bd8..e43e0981d 100644 --- a/Foundation/testsuite/src/FormatTest.cpp +++ b/Foundation/testsuite/src/FormatTest.cpp @@ -325,7 +325,13 @@ void FormatTest::testString() std::string foo("foo"); std::string s(format("%s", foo)); assert (s == "foo"); - + + s = format("%s", "foo"); + assert (s == "foo"); + + s = format("%s", static_cast("foo")); + assert (s == "foo"); + s = format("%5s", foo); assert (s == " foo");