xref: /PHP-7.3/ext/standard/tests/file/bug72330.phpt (revision f2c2a4be)
1--TEST--
2Bug #72330 (CSV fields incorrectly split if escape char followed by UTF chars)
3--SKIPIF--
4<?php
5if (setlocale(LC_ALL, "en_US.utf8", "en_AU.utf8", "ko_KR.utf8", "zh_CN.utf8", "de_DE.utf8", "es_EC.utf8", "fr_FR.utf8", "ja_JP.utf8", "el_GR.utf8", "nl_NL.utf8") === false) {
6    die('skip available locales not usable');
7}
8?>
9--FILE--
10<?php
11setlocale(LC_ALL, "en_US.utf8", "en_AU.utf8", "ko_KR.utf8", "zh_CN.utf8", "de_DE.utf8", "es_EC.utf8", "fr_FR.utf8", "ja_JP.utf8", "el_GR.utf8", "nl_NL.utf8");
12
13$utf_1 = chr(0xD1) . chr(0x81); // U+0440;
14$utf_2   = chr(0xD8) . chr(0x80); // U+0600
15
16$string = '"first #' . $utf_1 . $utf_2 . '";"second"';
17$fields = str_getcsv($string, ';', '"', "#");
18var_dump($fields);
19?>
20--EXPECT--
21array(2) {
22  [0]=>
23  string(11) "first #с؀"
24  [1]=>
25  string(6) "second"
26}
27