Use utf8::validate in StringLiteral::toString

This commit is contained in:
Alex Beregszaszi 2016-08-05 18:27:44 +01:00
parent 7945f41ccc
commit e8c2e87397

View File

@ -26,6 +26,7 @@
#include <libdevcore/CommonIO.h>
#include <libdevcore/CommonData.h>
#include <libdevcore/SHA3.h>
#include <libdevcore/UTF8.h>
#include <libsolidity/interface/Utils.h>
#include <libsolidity/ast/AST.h>
@ -854,6 +855,11 @@ bool StringLiteralType::operator==(const Type& _other) const
std::string StringLiteralType::toString(bool) const
{
int invalidSequence;
if (!dev::utf8::validate(m_value, invalidSequence))
return "literal_string (contains invalid UTF-8 sequence at position " + dev::toString(invalidSequence) + ")";
return "literal_string \"" + m_value + "\"";
}