Browse Source

DataStream fixes

• Removed dependency on ext-mbstring.
• Fixed bug where when using DataStream::consumeUntil and DataStream::consumeWhile where the column would be advanced whether the pointer was moved or not.
ns
Dustin Wilson 6 years ago
parent
commit
fd886d9a3a
  1. 1
      composer.json
  2. 16
      lib/DataStream.php

1
composer.json

@ -4,7 +4,6 @@
"type": "library",
"require": {
"php": "^7.0",
"ext-mbstring": "*",
"ext-ctype": "*",
"ext-hash": "*",
"mensbeam/intl": "*"

16
lib/DataStream.php

@ -324,7 +324,7 @@ class DataStream
# Otherwise, return a character token for the Unicode character whose code point
# is that number.
return mb_convert_encoding(pack('N', $number), 'UTF-8', 'UCS-4BE');
return \MensBeam\Intl\Encoding\UTF8::encode($number);
}
# Consume the maximum number of characters possible, with the consumed characters
@ -420,12 +420,14 @@ class DataStream
break;
}
if ($advancePointer && $char === "\n") {
$this->newlines[] = $this->data->posChar();
$this->_column = 1;
$this->_line++;
} else {
$this->_column++;
if ($advancePointer) {
if ($char === "\n") {
$this->newlines[] = $this->data->posChar();
$this->_column = 1;
$this->_line++;
} else {
$this->_column++;
}
}
$string .= $char;

Loading…
Cancel
Save