Output a string

@param  string    $str String to output
@param  false|int $row The optional row to output to
@param  false|int $col The optional column to output to
2111
public static function string( $str, $row = null, $col = null ) {
		if( $col !== null || $row !== null ) {
			Cursor::rowcol($row, $col);
		}
		fwrite(self::$stream, $str);
	}
795304
private function _writeBoolErr($row, $col, $value, $isError, $xfIndex)
	{
		$record = 0x0205;
		$length = 8;

		$header	= pack("vv",  $record, $length);
		$data	  = pack("vvvCC", $row, $col, $xfIndex, $value, $isError);
		$this->_append($header . $data);
		return 0;
	}
673838
private function _writeNote($row, $col, $note)
	{
		$note_length	= strlen($note);
		$record			= 0x001C;			// Record identifier
		$max_length		= 2048;				// Maximun length for a NOTE record

		// Length for this record is no more than 2048 + 6
		$length	= 0x0006 + min($note_length, 2048);
		$header	= pack("vv",   $record, $length);
		$data	= pack("vvv", $row, $col, $note_length);
		$this->_append($header . $data . substr($note, 0, 2048));

		for ($i = $max_length; $i < $note_length; $i += $max_length) {
			$chunk  = substr($note, $i, $max_length);
			$length = 0x0006 + strlen($chunk);
			$header = pack("vv",   $record, $length);
			$data   = pack("vvv", -1, 0, strlen($chunk));
			$this->_append($header.$data.$chunk);
		}
		return(0);
	}
910854
public function write_string($row, $col, $str, $format = null) {
        if (!isset($this->data[$row][$col])) {
            $this->data[$row][$col] = new MoodleODSCell();
        }
        if (is_array($format)) {
            $format = new MoodleODSFormat($format);
        }
        $this->data[$row][$col]->value = $str;
        $this->data[$row][$col]->type = 'string';
        $this->data[$row][$col]->format = $format;
        $this->data[$row][$col]->formula = null;
    }
826552
private function render($row = 0)
    {
        if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
            $rows = ($this->showSummary ? array_merge($this->rows, [$this->getSummary()]) : $this->rows);
            $this->output->reWrite($rows, !$this->showSummary);
        } else {
            $this->output->writeln($this->rows[$row]);
        }
    }
463013
function traceSubstring( $row, $col, $matrix, $val, $new )
    {
        $substring = array();
        while( $row >= 0 && $col >= 0 )
        {
            if ( $matrix->get( $row, $col ) == $val )
            {
                $substring[$col] = array( 'word' => $new[$col],
                                          'oldOffset' => $row );

                if ( $val > 1 )
                {
                    $val--;
                }
                else if ( $val == 1 )
                {
                    break;
                }

                $row--;
                $col--;
                if ( $row < 0 || $col < 0 )
                    break;
            }
        }
        return array( 'substring' => $substring,
                      'lastRow' => $row,
                      'lastCol' => $col );
    }
236767
def write(char, char_width, col, row, sgr)
			@lines[Integer(row)][Integer(col)] = [char, char_width, sgr.dup]
		end
877604
public function send(string $str): void
    {
        if ($this->need_headers) {
            $this->sendHttpHeaders();
        }
        $this->need_headers = false;

        fwrite($this->opt->getOutputStream(), $str);
    }
260558
public function row($r, $last = false)
	{
		$this->_strategy->output($this->beginRow());
		
		$values = array_values($r);
		$valuesl = count($values);
		
		for ( $i = 0 ; $i < $valuesl ; $i++ )
			$this->column($values[$i], $i+1 == $valuesl);
		
		$this->_strategy->output($this->endRow() . ($last ? '' : $this->rowSeparator()));
	}
157202
public static function strExists($str, $string)
    {
        $string = (string) $string;
        $str    = (string) $str;
        return strstr($string, $str) === false ? false : true;
    }
455975
public function getCellValue(int $col, int $row): string
    {
        if (!isset($this->structure[$row][$col])) {
            return '';
        }

        return $this->structure[$row][$col]['value'];
    }
1209578
public static void dumpRow(Map<String, Object> row)
   {
      for (Entry<String, Object> entry : row.entrySet())
      {
         Object value = entry.getValue();
         System.out.println(entry.getKey() + " = " + value + " ( " + (value == null ? "" : value.getClass().getName()) + ")");
      }
   }
277180
public void write(String str, int off, int len)  {
    	char[] chars = new char[len];
    	str.getChars(off, off+len, chars, 0);
    	buf.append(chars);
    }
949114
public void println(final String str) throws IOException {
        this.writer.print(str);
        this.writer.print("\r\n");
        this.writer.flush();
    }
1132732
public static void tputs(Writer out, String str, Object... params) throws IOException {
        int index = 0;
        int length = str.length();
        int ifte = IFTE_NONE;
        boolean exec = true;
        Stack<Object> stack = new Stack<Object>();
        while (index < length) {
            char ch = str.charAt(index++);
            switch (ch) {
                case '\\':
                    ch = str.charAt(index++);
                    if (ch >= '0' && ch <= '9') {
                        throw new UnsupportedOperationException(); // todo
                    } else {
                        switch (ch) {
                            case 'e':
                            case 'E':
                                if (exec) {
                                    out.write(27); // escape
                                }
                                break;
                            case 'n':
                                out.write('\n');
                                break;
//                        case 'l':
//                            rawPrint('\l');
//                            break;
                            case 'r':
                                if (exec) {
                                    out.write('\r');
                                }
                                break;
                            case 't':
                                if (exec) {
                                    out.write('\t');
                                }
                                break;
                            case 'b':
                                if (exec) {
                                    out.write('\b');
                                }
                                break;
                            case 'f':
                                if (exec) {
                                    out.write('\f');
                                }
                                break;
                            case 's':
                                if (exec) {
                                    out.write(' ');
                                }
                                break;
                            case ':':
                            case '^':
                            case '\\':
                                if (exec) {
                                    out.write(ch);
                                }
                                break;
                            default:
                                throw new IllegalArgumentException();
                        }
                    }
                    break;
                case '^':
                    ch = str.charAt(index++);
                    if (exec) {
                        out.write(ch - '@');
                    }
                    break;
                case '%':
                    ch = str.charAt(index++);
                    switch (ch) {
                        case '%':
                            if (exec) {
                                out.write('%');
                            }
                            break;
                        case 'p':
                            ch = str.charAt(index++);
                            if (exec) {
                                stack.push(params[ch - '1']);
                            }
                            break;
                        case 'P':
                            ch = str.charAt(index++);
                            if (ch >= 'a' && ch <= 'z') {
                                if (exec) {
                                    dv[ch - 'a'] = stack.pop();
                                }
                            } else if (ch >= 'A' && ch <= 'Z') {
                                if (exec) {
                                    sv[ch - 'A'] = stack.pop();
                                }
                            } else {
                                throw new IllegalArgumentException();
                            }
                            break;
                        case 'g':
                            ch = str.charAt(index++);
                            if (ch >= 'a' && ch <= 'z') {
                                if (exec) {
                                    stack.push(dv[ch - 'a']);
                                }
                            } else if (ch >= 'A' && ch <= 'Z') {
                                if (exec) {
                                    stack.push(sv[ch - 'A']);
                                }
                            } else {
                                throw new IllegalArgumentException();
                            }
                            break;
                        case '\'':
                            ch = str.charAt(index++);
                            if (exec) {
                                stack.push((int) ch);
                            }
                            ch = str.charAt(index++);
                            if (ch != '\'') {
                                throw new IllegalArgumentException();
                            }
                            break;
                        case '{':
                            int start = index;
                            while (str.charAt(index++) != '}');
                            if (exec) {
                                int v = Integer.valueOf(str.substring(start, index - 1));
                                stack.push(v);
                            }
                            break;
                        case 'l':
                            if (exec) {
                                stack.push(stack.pop().toString().length());
                            }
                            break;
                        case '+':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 + v2);
                            }
                            break;
                        case '-':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 - v2);
                            }
                            break;
                        case '*':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 * v2);
                            }
                            break;
                        case '/':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 / v2);
                            }
                            break;
                        case 'm':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 % v2);
                            }
                            break;
                        case '&':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 & v2);
                            }
                            break;
                        case '|':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 | v2);
                            }
                            break;
                        case '^':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 ^ v2);
                            }
                            break;
                        case '=':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 == v2);
                            }
                            break;
                        case '>':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 > v2);
                            }
                            break;
                        case '<':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 < v2);
                            }
                            break;
                        case 'A':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 != 0 && v2 != 0);
                            }
                            break;
                        case '!':
                            if (exec) {
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 == 0);
                            }
                            break;
                        case '~':
                            if (exec) {
                                int v1 = toInteger(stack.pop());
                                stack.push(~v1);
                            }
                            break;
                        case 'O':
                            if (exec) {
                                int v2 = toInteger(stack.pop());
                                int v1 = toInteger(stack.pop());
                                stack.push(v1 != 0 || v2 != 0);
                            }
                            break;
                        case '?':
                            if (ifte != IFTE_NONE) {
                                throw new IllegalArgumentException();
                            } else {
                                ifte = IFTE_IF;
                            }
                            break;
                        case 't':
                            if (ifte != IFTE_IF && ifte != IFTE_ELSE) {
                                throw new IllegalArgumentException();
                            } else {
                                ifte = IFTE_THEN;
                            }
                            exec = toInteger(stack.pop()) != 0;
                            break;
                        case 'e':
                            if (ifte != IFTE_THEN) {
                                throw new IllegalArgumentException();
                            } else {
                                ifte = IFTE_ELSE;
                            }
                            exec = !exec;
                            break;
                        case ';':
                            if (ifte == IFTE_NONE || ifte == IFTE_IF) {
                                throw new IllegalArgumentException();
                            } else {
                                ifte = IFTE_NONE;
                            }
                            exec = true;
                            break;
                        case 'i':
                            if (params.length >= 1) {
                                params[0] = toInteger(params[0]) + 1;
                            }
                            if (params.length >= 2) {
                                params[1] = toInteger(params[1]) + 1;
                            }
                            break;
                        case 'd':
                            out.write(Integer.toString(toInteger(stack.pop())));
                            break;
                        default:
                            throw new UnsupportedOperationException();
                    }
                    break;
                case '$':
                    if (str.charAt(index) == '<') {
                        // We don't honour delays, just skip
                        while (str.charAt(index++) != '>');
                    } else {
                        if (exec) {
                            out.write(ch);
                        }
                    }
                    break;
                default:
                    if (exec) {
                        out.write(ch);
                    }
                    break;
            }
        }
    }
1099009
private static void writeString(String str, DataOutput writer) throws IOException {
		if (str == null) {
			writer.writeByte(0);
		} else {
			int blocks = str.length() >> 15;
			// Use smallest number of bytes possible for number of blocks.
			if (blocks > 0x3FFFFF) {
				// Need 4 bytes
				writer.writeByte(0xc0 | (blocks >> 24));
				writer.writeByte(0xFF & (blocks >> 16));
				writer.writeByte(0xFF & (blocks >> 8));
			} else if (blocks > 0x3FFF) {
				// Need 3 bytes
				writer.writeByte(0x80 | (blocks >> 16));
				writer.writeByte(0xFF & (blocks >> 8));
			} else if (blocks > 0x3F) {
				// Need 2 bytes
				writer.writeByte(0x40 | (blocks >> 8));
			}
			// Need to add 1 to number of blocks to avoid confusion with 'null'
			writer.writeByte(0xFF & (blocks+1));
			int end = 0;
			for (int i=0; i<blocks; i++) {
				int start = end;
				end = (i+1)<<15;
				writer.writeUTF(str.substring(start, end));
			}
			writer.writeUTF(str.substring(end));
		}
	}
698322
public function prependOutput($str)
    {
        if (!isset($this->bev)) {
            return false;
        }
        return $this->bev->output->prepend($str);
    }