Skip to content

Commit

Permalink
Merge pull request #26 from imlcl/master
Browse files Browse the repository at this point in the history
[*] fixed UTF-8 name support
  • Loading branch information
tiamo authored May 3, 2019
2 parents 27aafa5 + 2b1fc9c commit d2feb9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ $writer = new \SPSS\Writer([
],
'variables' => [
[
'name' => 'VAR1',
'name' => 'VAR1', # For UTF-8, 64 / 3 = 21, mb_substr($var1, 0, 21);
'width' => 0,
'decimals' => 0
'format' => 5,
Expand Down
4 changes: 3 additions & 1 deletion src/Sav/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ public function write($data)
$var = new Variable($var);
}

if (! preg_match('/^[A-Za-z0-9_]+$/', $var->name)) {
#if (! preg_match('/^[A-Za-z0-9_]+$/', $var->name)) {
# UTF-8 and '.' characters could pass here
if (! preg_match('/^[A-Za-z0-9_\.\x{4e00}-\x{9fa5}]+$/u', $var->name)) {
throw new \InvalidArgumentException(
sprintf('Variable name `%s` contains an illegal character.', $var->name)
);
Expand Down

0 comments on commit d2feb9d

Please sign in to comment.