Menu

#3 Latest code breaks on long string

1.0
closed
None
2017-12-27
2017-12-08
No

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)

Discussion

  • DuffsDevice

    DuffsDevice - 2017-12-15

    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

     
  • DuffsDevice

    DuffsDevice - 2017-12-27
     
  • DuffsDevice

    DuffsDevice - 2017-12-27
    • status: open --> closed
    • assigned_to: DuffsDevice
     
  • DuffsDevice

    DuffsDevice - 2017-12-27

    Fixed on Github :)

     

Log in to post a comment.