fixed: FileLog didn't save an utf8 sequence

git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1155 e52654a7-88a9-db11-a3e9-0013d4bc506e
master
Tomasz Sowa 4 years ago
parent e971e1ef9b
commit 8b3ae14d9a

@ -103,20 +103,21 @@ void FileLog::open_file()
void FileLog::PutBuffer(PT::WTextStream * buffer, std::ostream & out_stream)
{
char utf8_buffer[256];
std::size_t buffer_len = sizeof(utf8_buffer) / sizeof(char);
std::size_t utf8_sequence_max_length = 10;
std::size_t index = 0;
PT::WTextStream::const_iterator i = buffer->begin();
while( i != buffer->end() )
{
utf8_buffer[index++] = *i;
if( index + 10 > sizeof(utf8_buffer) / sizeof(char) )
if( index + utf8_sequence_max_length > buffer_len )
{
out_stream.write(utf8_buffer, index);
index = 0;
}
index += PT::IntToUTF8(*i, utf8_buffer + index, buffer_len - index);
++i;
}

Loading…
Cancel
Save