Skip to content

Commit 383cf52

Browse files
author
Martin Brecht-Precht
committed
Added encoding detection to the lastChar and firstChar methods.
1 parent 00f1643 commit 383cf52

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/StringBuilder.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public function charAt($position)
268268
*/
269269
public function firstChar()
270270
{
271-
return mb_substr($this->string, 0, 1);
271+
return mb_substr($this->string, 0, 1, mb_detect_encoding($this->string));
272272
}
273273

274274
/**
@@ -278,7 +278,7 @@ public function firstChar()
278278
*/
279279
public function lastChar()
280280
{
281-
return mb_substr($this->string, -1);
281+
return mb_substr($this->string, -1, null, mb_detect_encoding($this->string));
282282
}
283283

284284
/**

0 commit comments

Comments
 (0)