diff --git a/lessc.inc.php b/lessc.inc.php index aaa86930..e66d300d 100644 --- a/lessc.inc.php +++ b/lessc.inc.php @@ -1647,6 +1647,14 @@ public function compile($string, $name = null) { $locale = setlocale(LC_NUMERIC, 0); setlocale(LC_NUMERIC, "C"); + $internal_encoding = NULL; + // only if mbstring installed + if (function_exists('mb_orig_strlen')) { + $internal_encoding = ini_get('mbstring.internal_encoding'); + if(!is_null($internal_encoding)){ + ini_set('mbstring.internal_encoding', NULL); + } + } $this->parser = $this->makeParser($name); $root = $this->parser->parse($string); @@ -1666,6 +1674,9 @@ public function compile($string, $name = null) { $this->formatter->block($this->scope); $out = ob_get_clean(); setlocale(LC_NUMERIC, $locale); + if(!is_null($internal_encoding)){ + ini_set('mbstring.internal_encoding', $internal_encoding); + } return $out; } @@ -2106,6 +2117,7 @@ public function __construct($lessc, $sourceName = null) { } public function parse($buffer) { + $this->count = 0; $this->line = 1; @@ -2126,6 +2138,7 @@ public function parse($buffer) { $lastCount = $this->count; while (false !== $this->parseChunk()); + if ($this->count != strlen($this->buffer)) $this->throwError(); diff --git a/tests/inputs/utf_symbols.less b/tests/inputs/utf_symbols.less new file mode 100644 index 00000000..7ba46eaf --- /dev/null +++ b/tests/inputs/utf_symbols.less @@ -0,0 +1,15 @@ +ul { + li { + &:before { + content: "—"; + } + } + &:after { + content: "©—©"; + } +} +div { + &:before { + content: "Привет, мир!"; + } +} diff --git a/tests/outputs/utf_symbols.css b/tests/outputs/utf_symbols.css new file mode 100644 index 00000000..dead8390 --- /dev/null +++ b/tests/outputs/utf_symbols.css @@ -0,0 +1,9 @@ +ul li:before { + content: "—"; +} +ul:after { + content: "©—©"; +} +div:before { + content: "Привет, мир!"; +}