Community
    • Login

    Character count bug

    Scheduled Pinned Locked Moved General Discussion
    2 Posts 2 Posters 2.0k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Eduardo Pinheiro GuerraE
      Eduardo Pinheiro Guerra
      last edited by

      I believe that when there is a “–” character it is not counted.
      It is not the “hyphen”, it is the “dash”

      For example, as the counting in the software is shown:

      EITHALOG LOGISTICA E TRANSPORTES EI = 35 characters
      EITHALO- LOGISTICA E TRANSPORTES EI = 35 characters
      EITHALO– LOGISTICA E TRANSPORTES EI = 34 characters

      If you copy and paste from the forum, it does not show the error, so I’m making a file available for viewing.

      It is a file that is generated automatically through a logistic control software.

      https://www.dropbox.com/s/6bl5951wf6faaep/Notepad%2B%2B.zip?dl=0

      Claudia FrankC 1 Reply Last reply Reply Quote 0
      • Claudia FrankC
        Claudia Frank @Eduardo Pinheiro Guerra
        last edited by

        @Eduardo-Pinheiro-Guerra

        you are correct, and it looks like more chars are affected - every char within 0x80 and 0xBF.
        But if you use “convert to utf-8”, than it is correctly counted.
        The issue seems to be in ScintillaEditView.h

        long getUnicodeSelectedLength() const
        {
        	// return -1 if it's multi-selection or rectangle selection
        	if ((execute(SCI_GETSELECTIONS) > 1) || execute(SCI_SELECTIONISRECTANGLE))
        		return -1;
        	auto size_selected = execute(SCI_GETSELTEXT);
        	char *selected = new char[size_selected + 1];
        	execute(SCI_GETSELTEXT, 0, reinterpret_cast<LPARAM>(selected));
        	char *c = selected;
        	long length = 0;
        	while(*c != '\0')
        	{
        		if( (*c & 0xC0) != 0x80)
        			++length;
        		++c;
        	}
        	delete [] selected;
        	return length;
        }
        

        but I’m unsure why this is done.

        Cheers
        Claudia

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors