Sync develop with master #4
3 changed files with 35 additions and 13 deletions
|
|
@ -8,6 +8,8 @@
|
|||
namespace fc
|
||||
{
|
||||
|
||||
std::string prune_invalid_utf8( const std::string& str );
|
||||
|
||||
bool is_utf8( const std::string& str );
|
||||
|
||||
/** Decodes utf 8 std::string into unicode string.
|
||||
|
|
|
|||
20
src/utf8.cpp
20
src/utf8.cpp
|
|
@ -3,16 +3,36 @@
|
|||
#include "utf8/checked.h"
|
||||
#include "utf8/core.h"
|
||||
#include "utf8/unchecked.h"
|
||||
#include <websocketpp/utf8_validator.hpp>
|
||||
|
||||
#include <assert.h>
|
||||
#include <fc/log/logger.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace fc {
|
||||
|
||||
bool is_utf8( const std::string& str )
|
||||
{
|
||||
auto itr = utf8::find_invalid(str.begin(), str.end());
|
||||
return utf8::is_valid( str.begin(), str.end() );
|
||||
}
|
||||
|
||||
string prune_invalid_utf8( const string& str ) {
|
||||
string result;
|
||||
|
||||
auto itr = utf8::find_invalid(str.begin(), str.end());
|
||||
if( itr == str.end() ) return str;
|
||||
|
||||
result = string( str.begin(), itr );
|
||||
while( itr != str.end() ) {
|
||||
++itr;
|
||||
auto start = itr;
|
||||
itr = utf8::find_invalid( start, str.end());
|
||||
result += string( start, itr );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void decodeUtf8(const std::string& input, std::wstring* storage)
|
||||
{
|
||||
assert(storage != nullptr);
|
||||
|
|
|
|||
2
vendor/websocketpp
vendored
2
vendor/websocketpp
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit c5510d6de04917812b910a8dd44735c1f17061d9
|
||||
Subproject commit 378437aecdcb1dfe62096ffd5d944bf1f640ccc3
|
||||
Loading…
Reference in a new issue