Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV Import from Excel #1321

Closed
trob opened this issue Sep 17, 2014 · 1 comment
Closed

CSV Import from Excel #1321

trob opened this issue Sep 17, 2014 · 1 comment

Comments

@trob
Copy link

trob commented Sep 17, 2014

http://www.fabrikar.com/forums/index.php?threads/csv-import-problem-sign-diamond-with-question-mark-at-end-of-data.39532/#post-198651
importcsv.php (line 1448) is doing

if ($this->inPutFormat == 'excel' || $this->inPutFormat == 'fabrikexcel')
{
    $encFrom = $this->inPutFormat == 'fabrikexcel' ? 'UTF-16LE' : 'Windows-1252';

    foreach ($arr_row as $k => $v)
    {
        $arr_row[$k] = trim($arr_row[$k]);

        if ($arr_row[$k] !== '')
        {
            $arr_row[$k] = iconv($encFrom, 'UTF-8', $arr_row[$k] . "\0");
            $arr_row[$k] = str_replace('""', '"', $arr_row[$k]);
            $arr_row[$k] = preg_replace("/^\"(.*)\"$/sim", "$1", $arr_row[$k]);
        }
    }
}

If I delete . "\0" it's ok. Why is it there? Is it necessary for UTF-16LE?

@cheesegrits
Copy link
Member

I have a feeling that may just be because it looks like we copied the code from an example on the PHP manual page for fgetcsv page:

http://php.net/manual/en/function.fgetcsv.php#101295

... which was actually using UCS2 encoding. I don't think either UTF-16LE or Windows-1252 use null terminated lines, they should both use either \r\n or \n.

I'd suggest we just try removing it and see what happens. :)

trob added a commit that referenced this issue Oct 22, 2014
@trob trob closed this as completed Oct 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants