Skip to content

Explode of CSV with invalid characters #13

@vatri

Description

@vatri

I just work for on a commercial project. The client of mine wants to import some CSV that includes a strange characters... OpenOffice does replace these with "[?]" but your CSV parser recognizes these characters as \n and moves the rest of the line into new line...

Anyways,
I added following function and called it within fromString(), fromFile() and fromStream() methods.

private function _removeStrangeCharacters($string){
    return mb_convert_encoding($string, 'UTF-8', "UTF-8");
}

i.e.

public function fromFile( $file ) {
    if ( file_exists($file) && is_readable($file) ){
         $this->data = file_get_contents($file);
         $this->data = $this->_removeStrangeCharacters($this->data);
     }
     return $this;
}

I actually worked on 2.0.1 version... Not sure if this is fixed in new versions - and don't have time to check now. But I hope to see this problem solved in a following releases. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions