SSIS - Flat file always ANSI never UTF-8 encoded

前端 未结 6 1180
猫巷女王i
猫巷女王i 2020-12-08 21:11

Have a pretty straight forward SSIS package:

  • OLE DB Source to get data via a view, (all string columns in db table nvarchar or nchar).
  • Derived Column
6条回答
  •  甜味超标
    2020-12-08 22:10

    Adding explanation to the answers ...

    setting the CodePage to 65001 (but do NOT check the Unicode checkbox on the file source), should generate a UTF-8 file. (yes, the data types internally also should be nvarchar, etc).

    But the file that is produced from SSIS does not have a BOM header (Byte Order Marker), so some programs will assume it is still ASCII, not UTF-8. I've seen this confirmed by MS employees on MSDN, as well as confirmed by testing.

    The file append solution is a way around this - by creating a blank file WITH the proper BOM, and then appending data from SSIS, the BOM header remains in place. If you tell SSIS to overwrite the file, it also loses the BOM.

    Thanks for the hints here, it helped me figure out the above detail.

提交回复
热议问题