What Client want ?
We have client which generate tones of report from project data in csv format for their BI(Business Intell) group.
File downloaded form server is encoded with UTF-8 without BOM (Byte Order Marker), that is fine and also stranded way. A standard saying is do not add BOM for UTF-8.
But when same report file(.csv) is opened with MS Excel, it is not able to detect encoding of file because absence of BOM for UTF-8, and French character in file shows some random symbol.
What we did ?
We told them to open same file notepad++, because it detect the encoding and mark encode to UTF-8-BOM so it can open in Excel with proper encoding for special character. That is working fine and also good solution.
What Client Replied ?
Client replied that they dont want open same file notepad++, instead it should open in Excel with correct encoding.
This is the story to dig up little into BOM (Byte Order Marker)
and JVM s UTF-8 behavior
What JVM Expect for UTF-8 Encoding ?
Whenever you read file using java with UTF-8, JVM is not excepting BOM character at starting of InputStream. If their is any BOM character present, JVM consider it as data of file.
JVM not expecting BOM for UTF-8, which standard from UNICODE
Finally we have added BOM for UTF-8 encoding for file. And removing BOM character while reading the file. This is fix we have given to client.
But may be in future client will come to us saying that they have one tools which consumes csv format data and while reading data,tool getting weird character at staring of file. Which is because client tool expecting file with UTF-8 encoding without BOM and tool considering BOM Character as data of input file.
But client is client, nobody beat them.
No comments:
Post a Comment