Log class has the Stream class as a base class now
- implemented some missing operators<<(...) - removed Manipulators: l1, l2, l3, l4, lend, lsave - PascalCase to snake_case in Log added to Stream: virtual bool is_char_stream() const = 0; virtual bool is_wchar_stream() const = 0; virtual char get_char(size_t index) const = 0; virtual wchar_t get_wchar(size_t index) const = 0; virtual Stream & operator<<(const Stream & stream) = 0;
This commit is contained in:
@@ -291,6 +291,46 @@ return len;
|
||||
}
|
||||
|
||||
|
||||
// new function, need to be tested a little more especially when sizeof(wchar_t) is 2
|
||||
size_t utf8_to_int(const Stream & utf8, size_t stream_index, int & res, bool & correct)
|
||||
{
|
||||
size_t i, len;
|
||||
unsigned char uz;
|
||||
|
||||
res = 0;
|
||||
correct = false;
|
||||
len = 0;
|
||||
|
||||
if( stream_index < utf8.size() )
|
||||
{
|
||||
uz = utf8.get_char(stream_index);
|
||||
|
||||
if( !private_namespace::utf8_to_int_first_octet(uz, len, res) )
|
||||
return 1;
|
||||
|
||||
if( stream_index + len < utf8.size() + 1 )
|
||||
{
|
||||
for(i=1 ; i<len ; ++i)
|
||||
{
|
||||
uz = utf8.get_char(stream_index + i);
|
||||
|
||||
if( !private_namespace::utf8_to_int_add_next_octet(uz, res) )
|
||||
return i;
|
||||
}
|
||||
|
||||
if( utf8_check_range(res, len) )
|
||||
correct = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
len = utf8.size() - stream_index;
|
||||
}
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user