diff --git a/src/quickRdfIo/TriGParser.php b/src/quickRdfIo/TriGParser.php
index 0d8470c..5b3b637 100644
--- a/src/quickRdfIo/TriGParser.php
+++ b/src/quickRdfIo/TriGParser.php
@@ -151,8 +151,8 @@ public function next(): void {
}
});
while (!$this->input->eof() && $this->quadsBuffer->count() === 0) {
- $p = strlen($this->chunk) + self::CHUNK_SIZE - 1;
$this->chunk .= $this->input->read(self::CHUNK_SIZE);
+ $p = strlen($this->chunk) - 1;
$cp = ord($this->chunk[$p]);
if ($cp < 127) {
// chunk ends with a single-byte UTF-8 character - just parse whole chunk
@@ -168,7 +168,6 @@ public function next(): void {
$this->parser->parseChunk(substr($this->chunk, 0, $p));
$this->chunk = substr($this->chunk, $p);
}
- $this->parser->parseChunk($x);
}
if ($this->input->eof()) {
$this->parser->end();
diff --git a/tests/TriGParserTest.php b/tests/TriGParserTest.php
index c5d35bc..2e4ade8 100644
--- a/tests/TriGParserTest.php
+++ b/tests/TriGParserTest.php
@@ -105,7 +105,6 @@ public function testMatchesNQuadsSerializer(): void {
* @return void
*/
public function testUtfChunk(): void {
- $input .= '# ' . str_repeat('𐍈', TriGParser::CHUNK_SIZE);
$parser = new TriGParser(new DF());
$iter = $parser->parse(file_get_contents(__DIR__ . '/files/issue4.ttl'));
$triples = iterator_to_array($iter);
diff --git a/tests/files/issue4.ttl b/tests/files/issue4.ttl
new file mode 100644
index 0000000..d72a1ea
--- /dev/null
+++ b/tests/files/issue4.ttl
@@ -0,0 +1,234 @@
+@prefix schema: .
+@prefix gndo: .
+@prefix lib: .
+@prefix owl: .
+@prefix xsd: .
+@prefix skos: .
+@prefix rdfs: .
+@prefix editeur: .
+@prefix geo: .
+@prefix umbel: .
+@prefix naf: .
+@prefix rdau: .
+@prefix sf: .
+@prefix bflc: .
+@prefix thesoz: .
+@prefix dcterms: .
+@prefix isbd: .
+@prefix foaf: .
+@prefix mesh: .
+@prefix ram: .
+@prefix mo: .
+@prefix marcRole: .
+@prefix agrelon: .
+@prefix dcmitype: .
+@prefix nsogg: .
+@prefix dnbt: .
+@prefix dbp: .
+@prefix embne: .
+@prefix rdf: .
+@prefix dnb_intern: .
+@prefix madsrdf: .
+@prefix cidoc: .
+@prefix v: .
+@prefix ebu: .
+@prefix wdrs: .
+@prefix gbv: .
+@prefix bibo: .
+@prefix agrovoc: .
+@prefix lcsh: .
+@prefix dc: .
+
+ a gndo:RoyalOrMemberOfARoyalHouse;
+ wdrs:describedby .
+
+ dcterms:license ;
+ dcterms:modified "2022-09-27T16:55:36.000"^^xsd:dateTime;
+ gndo:descriptionLevel .
+
+ gndo:gndIdentifier "118560077";
+ foaf:page ;
+ owl:sameAs , ,
+ , ,
+ ;
+ gndo:oldAuthorityNumber "(DE-588)1089438923";
+ owl:sameAs ;
+ dnbt:deprecatedUri "https://d-nb.info/gnd/1089438923";
+ gndo:oldAuthorityNumber "(DE-588)1089894554";
+ owl:sameAs ;
+ dnbt:deprecatedUri "https://d-nb.info/gnd/1089894554";
+ gndo:oldAuthorityNumber "(DE-588a)118560077", "(DE-588c)4029678-7";
+ gndo:variantNameForThePerson "Karl Franz Joseph Ludwig Hubert Georg Otto Maria I.";
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138915 .
+
+_:node1hm16sit8x6138915 gndo:personalName "Karl Franz Joseph Ludwig Hubert Georg Otto Maria";
+ gndo:counting "I." .
+
+ gndo:variantNameForThePerson "Karl IV., Ungarn, König";
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138916 .
+
+_:node1hm16sit8x6138916 gndo:personalName "Karl";
+ gndo:counting "IV.";
+ gndo:nameAddition "Ungarn, König" .
+
+ gndo:variantNameForThePerson "Karlo IV., Ungarn, König";
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138917 .
+
+_:node1hm16sit8x6138917 gndo:personalName "Karlo";
+ gndo:counting "IV.";
+ gndo:nameAddition "Ungarn, König" .
+
+ gndo:variantNameForThePerson "IV. Károly magyar király";
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138918 .
+
+_:node1hm16sit8x6138918 gndo:personalName "IV. Károly magyar király" .
+
+ gndo:variantNameForThePerson "Karel III., Böhmen, König";
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138919 .
+
+_:node1hm16sit8x6138919 gndo:personalName "Karel";
+ gndo:counting "III.";
+ gndo:nameAddition "Böhmen, König" .
+
+ gndo:variantNameForThePerson "Carlo I.";
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138920 .
+
+_:node1hm16sit8x6138920 gndo:personalName "Carlo";
+ gndo:counting "I." .
+
+ gndo:variantNameForThePerson "Karol I.";
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138921 .
+
+_:node1hm16sit8x6138921 gndo:personalName "Karol";
+ gndo:counting "I." .
+
+ gndo:variantNameForThePerson "Charles I.";
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138922 .
+
+_:node1hm16sit8x6138922 gndo:personalName "Charles";
+ gndo:counting "I." .
+
+ gndo:variantNameForThePerson "Karl I., Österreich-Ungarn, Kaiser";
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138923 .
+
+_:node1hm16sit8x6138923 gndo:personalName "Karl";
+ gndo:counting "I.";
+ gndo:nameAddition "Österreich-Ungarn, Kaiser" .
+
+ gndo:variantNameForThePerson "Karl Franz Joseph, Österreich, Erzherzog";
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138924 .
+
+_:node1hm16sit8x6138924 gndo:personalName "Karl Franz Joseph";
+ gndo:nameAddition "Österreich, Erzherzog" .
+
+ gndo:variantNameForThePerson "Karl Franz Josef, Österreich, Erzherzog";
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138925 .
+
+_:node1hm16sit8x6138925 gndo:personalName "Karl Franz Josef";
+ gndo:nameAddition "Österreich, Erzherzog" .
+
+ gndo:variantNameForThePerson "Karl I, Kaiser von Österreich";
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138926 .
+
+_:node1hm16sit8x6138926 gndo:personalName "Karl";
+ gndo:counting "I";
+ gndo:nameAddition "Kaiser von Österreich" .
+
+ gndo:variantNameForThePerson "Karl I, Empereur d'Autriche"@fr;
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138927 .
+
+_:node1hm16sit8x6138927 gndo:personalName "Karl";
+ gndo:counting "I";
+ gndo:nameAddition "Empereur d'Autriche" .
+
+ gndo:variantNameForThePerson "Karl I, Emperor of Austria"@en;
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138928 .
+
+_:node1hm16sit8x6138928 gndo:personalName "Karl";
+ gndo:counting "I";
+ gndo:nameAddition "Emperor of Austria" .
+
+ gndo:variantNameForThePerson "Karl IV, König von Ungarn";
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138929 .
+
+_:node1hm16sit8x6138929 gndo:personalName "Karl";
+ gndo:counting "IV";
+ gndo:nameAddition "König von Ungarn" .
+
+ gndo:variantNameForThePerson "Karl IV, Roi d'Hongrie";
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138930 .
+
+_:node1hm16sit8x6138930 gndo:personalName "Karl";
+ gndo:counting "IV";
+ gndo:nameAddition "Roi d'Hongrie" .
+
+ gndo:variantNameForThePerson "Karl IV, King of Hungary";
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138931 .
+
+_:node1hm16sit8x6138931 gndo:personalName "Karl";
+ gndo:counting "IV";
+ gndo:nameAddition "King of Hungary" .
+
+ gndo:variantNameForThePerson "Österreich, Karl I. von";
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138932 .
+
+_:node1hm16sit8x6138932 gndo:forename "Karl I.";
+ gndo:prefix "von";
+ gndo:surname "Österreich" .
+
+ gndo:variantNameForThePerson "Карл I од Аустрије"@sr;
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138933 .
+
+_:node1hm16sit8x6138933 gndo:personalName "Карл I од Аустрије" .
+
+ gndo:variantNameForThePerson "Карл I (император Австрии)"@sr-Cyrl;
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138934 .
+
+_:node1hm16sit8x6138934 gndo:personalName "Карл I (император Австрии)" .
+
+ gndo:variantNameForThePerson "Карл I (імператор Австро-Угорщини)"@ru;
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138935 .
+
+_:node1hm16sit8x6138935 gndo:personalName "Карл I (імператор Австро-Угорщини)" .
+
+ gndo:variantNameForThePerson "Карл I (Австро-Унгария)"@uk;
+ gndo:variantNameEntityForThePerson _:node1hm16sit8x6138936 .
+
+_:node1hm16sit8x6138936 gndo:personalName "Карл I (Австро-Унгария)" .
+
+ gndo:preferredNameForThePerson "Karl I., Österreich, Kaiser";
+ gndo:preferredNameEntityForThePerson _:node1hm16sit8x6138937 .
+
+_:node1hm16sit8x6138937 gndo:personalName "Karl";
+ gndo:counting "I.";
+ gndo:nameAddition "Österreich, Kaiser" .
+
+ gndo:familialRelationship ;
+ agrelon:hasSpouse ;
+ gndo:familialRelationship ;
+ agrelon:hasParent ;
+ gndo:familialRelationship ;
+ agrelon:hasAuntUncle ;
+ gndo:familialRelationship ;
+ agrelon:hasChild ;
+ gndo:relatedTerm ;
+ gndo:gender ;
+ gndo:titleOfNobility , ;
+ gndo:gndSubjectCategory ;
+ gndo:geographicAreaCode ,
+ , ,
+ ;
+ gndo:biographicalOrHistoricalInformation "1914 Thronanwärter, 1916-1918 Kaiser von Österreich und König von Ungarn, 1917 Sonderfriedensbemühungen, 1918 Regierungsverzicht und schweizer Exil; 1921 zwei gescheiterte Versuche der Rückkehr auf den ungarischen Thron; 2004 Seligsprechung durch Papst Johannes Paul II."@de;
+ gndo:placeOfBirth ;
+ gndo:placeOfActivity , ;
+ gndo:placeOfExile ;
+ gndo:placeOfDeath ;
+ owl:sameAs ;
+ gndo:professionOrOccupation _:node1hm16sit8x6138938 .
+
+_:node1hm16sit8x6138938 a rdf:Seq;
+ rdf:_1 .
+
+ gndo:dateOfBirth "1887-08-17"^^xsd:date;
+ gndo:dateOfDeath "1922-04-01"^^xsd:date .
+