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.
split-manual
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", "type": "library",
"require": { "require": {
"php": "^7.0", "php": "^7.0",
"ext-mbstring": "*",
"ext-ctype": "*", "ext-ctype": "*",
"ext-hash": "*", "ext-hash": "*",
"mensbeam/intl": "*" "mensbeam/intl": "*"

16
lib/DataStream.php

@ -324,7 +324,7 @@ class DataStream
# Otherwise, return a character token for the Unicode character whose code point # Otherwise, return a character token for the Unicode character whose code point
# is that number. # 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 # Consume the maximum number of characters possible, with the consumed characters
@ -420,12 +420,14 @@ class DataStream
break; break;
} }
if ($advancePointer && $char === "\n") { if ($advancePointer) {
$this->newlines[] = $this->data->posChar(); if ($char === "\n") {
$this->_column = 1; $this->newlines[] = $this->data->posChar();
$this->_line++; $this->_column = 1;
} else { $this->_line++;
$this->_column++; } else {
$this->_column++;
}
} }
$string .= $char; $string .= $char;

Loading…
Cancel
Save