Problem with german umlauts in generated CSV file

2019-07-14 01:17发布

Problem with german umlauts in generated CSV file using Grails

Hi,

I have a problem with the german umlauts like ä,ö,ü in generated CSV files using Grails, here is the snippet of my code

def report = {
    //....
    response.setContentType("text/csv; charset=UTF-8");
    response.setHeader("Content-disposition", "attachment; filename=" + params.dateiname + "");   
    response.setCharacterEncoding("UTF-8")   
    response.outputStream << datalist  // in datalist are the data in CSV format like "File";"Date";"Customer" etc.
}

After calling the closure and saving the file the german umlauts are diplayed wrong with Excel, but they are displayed correct when I open the file with notepad.

Does anyone have an idea of this Problem?

Thanks in advance!

mozilla20

1条回答
淡お忘
2楼-- · 2019-07-14 01:37

IIRC, Excel assumes ANSI CSV encoding. Explicit BOM helps sometimes: Microsoft Excel mangles Diacritics in .csv files?

查看更多
登录 后发表回答