Latest code breaks on long string
Lightweight C++11 library for embedding Unicode
Brought to you by:
ijake1111
Latest code for svn doesn't correctly work with long strings:
#include <iostream>
#include <string>
#include <tinyutf8.h>
using namespace std;
utf8_string str;
utf8_string waiting;
void SetText(const utf8_string& in)
{
str.clear();
waiting.clear();
waiting.append(in);
}
bool AddNextChar()
{
if(!waiting.empty())
{
char32_t ch = waiting[0];
str.push_back(ch);
waiting.erase(0);
return true;
}
std::cout << "Empty? " << waiting.cpp_str() << std::endl;
return false;
}
void Output()
{
std::cout << str.cpp_str() << std::endl;
}
int main()
{
SetText(std::string("From somewhere, a transmission..."));
while(AddNextChar())
{
Output();
}
}
This will output F's indefinitely.
Sadly, i can't use latest release (pre sso) either, as it's buggy too (eats last character in mixed non-ascii/ascii string, doesn't happen with svn code, though)
Hi,
I was able to reproduced the bug myself.
As I am cronically busy with Work, you may have a look at the code yourself. I will try to spare some time over the holidays to unit test the library and fix whats broken.
Sorry for this inconvenience and sorry, that I cannot offer you more than that at the moment.
Have a nice Weekend,
Jakob
The bug is now fixed on https://github.com/DuffsDevice/tinyutf8
Fixed on Github :)