CsvFile::fetchWidth: Bitrix method

      
<?php 
//  Bitrix\Translate\IO\CsvFile :: fetchWidth()
//  /dist/bitrix/modules/translate/lib/io/csvfile.php:436

    
protected function fetchWidth()
    {
        
$str '';
        
$ind 1;
        
$jnd 0;
        
$result = array();

        while (
$this->currentPosition <= $this->fileSize)
        {
            
$ch $this->buffer[$this->bufferPosition];
            if (
$ch == "\r" || $ch == "\n")
            {
                while (
$this->currentPosition <= $this->fileSize)
                {
                    
$this->incrementCurrentPosition();
                    
$ch $this->buffer[$this->bufferPosition];
                    if (
$ch != "\r" && $ch != "\n")
                    {
                        break;
                    }
                }
                if (
$this->firstHeader)
                {
                    
$this->firstHeader false;
                    
$result = array();
                    
$ind 1;
                    
$str '';
                    continue;
                }

                
$result[] = $str;
                return 
$result;
            }
            if (
$ind == $this->widthMap[$jnd])
            {
                
$result[] = $str$ch;
                
$str '';
                
$this->incrementCurrentPosition();
                
$ind ++;
                
$jnd ++;
                continue;
            }

            
//inline "call"
            
$this->currentPosition ++;
            
$this->bufferPosition ++;
            if(
$this->bufferPosition >= $this->bufferSize)
            {
                
$this->buffer $this->read1024 1024);
                
$this->bufferSize BinaryString::getLength($this->buffer);
                
$this->bufferPosition 0;
            }

            
$ind ++;
            
$str .= $ch;
        }

        if (
$str <> '')
        {
            
$result[] = $str;
        }

        if(empty(
$result))
        {
            return 
false;
        }

        return 
$result;
    }