Import-CSV / Export-CSV with special characters / Bug?

Is there a way to make import/export-csv work with special characters? Try this:

cd $home
md öttö
dir | select-object Name | export-csv test.csv
import-csv test.csv

All special characters appear as "?".  

-Tobias

Parents
  • Hi Tobias,

    I have try this on german Windows Vista and it worked with german "Umlauten"

    dir | select-object Name | export-csv test.csv -Encoding unicode
    import-csv test.csv

    Name
    ----
    öttö
    test.csv

    Best regards
    Martin

  • Thanks, that's it. You can control Unicode encoding when you use Export-CSV. The problem occured with csv files in ANSI format generated by Excel. They show special characters correctly but when you import them via Import-CSV, special characters change.

    I still do not understand why special characters show correctly in ANSI csv files but get corrupted once imported via Import-CSV. The workaround seems to indeed be to make sure they are stored as unicode.

    Thanks!

     

Reply
  • Thanks, that's it. You can control Unicode encoding when you use Export-CSV. The problem occured with csv files in ANSI format generated by Excel. They show special characters correctly but when you import them via Import-CSV, special characters change.

    I still do not understand why special characters show correctly in ANSI csv files but get corrupted once imported via Import-CSV. The workaround seems to indeed be to make sure they are stored as unicode.

    Thanks!

     

Children