diff --git a/include/fc/crypto/sha224.hpp b/include/fc/crypto/sha224.hpp index a0da04d..9ea9290 100644 --- a/include/fc/crypto/sha224.hpp +++ b/include/fc/crypto/sha224.hpp @@ -1,6 +1,7 @@ #pragma once #include #include +#include #include namespace fc @@ -24,7 +25,7 @@ class sha224 static sha224 hash( const T& t ) { sha224::encoder e; - e << t; + fc::raw::pack(e,t); return e.result(); } diff --git a/include/fc/io/enum_type.hpp b/include/fc/io/enum_type.hpp index 0406976..e41770c 100644 --- a/include/fc/io/enum_type.hpp +++ b/include/fc/io/enum_type.hpp @@ -17,7 +17,7 @@ namespace fc enum_type(){} - operator IntType()const { return static_cast(value); } + explicit operator IntType()const { return static_cast(value); } operator EnumType()const { return value; } operator std::string()const { return fc::reflector::to_string(value); } diff --git a/include/fc/utf8.hpp b/include/fc/utf8.hpp index d6afbaa..3af2abe 100644 --- a/include/fc/utf8.hpp +++ b/include/fc/utf8.hpp @@ -8,6 +8,8 @@ namespace fc { +bool is_utf8( const std::string& str ); + /** Decodes utf 8 std::string into unicode string. @param input - input string to be decoded and stored in 'storage' @param storage - buffer for converted text. Cannot be nullptr. diff --git a/src/utf8.cpp b/src/utf8.cpp index 1ddabcf..0bab5e0 100644 --- a/src/utf8.cpp +++ b/src/utf8.cpp @@ -6,22 +6,26 @@ #include -namespace fc -{ +namespace fc { -void decodeUtf8(const std::string& input, std::wstring* storage) - { - assert(storage != nullptr); + bool is_utf8( const std::string& str ) + { + return utf8::is_valid( str.begin(), str.end() ); + } - utf8::utf8to32(input.begin(), input.end(), std::back_inserter(*storage)); - } + void decodeUtf8(const std::string& input, std::wstring* storage) + { + assert(storage != nullptr); -void encodeUtf8(const std::wstring& input, std::string* storage) - { - assert(storage != nullptr); + utf8::utf8to32(input.begin(), input.end(), std::back_inserter(*storage)); + } - utf8::utf32to8(input.begin(), input.end(), std::back_inserter(*storage)); - } + void encodeUtf8(const std::wstring& input, std::string* storage) + { + assert(storage != nullptr); + + utf8::utf32to8(input.begin(), input.end(), std::back_inserter(*storage)); + } } ///namespace fc