The requirement I'm working on requires to read a CSV file with temperature measurements. But Fahrenheit or Celcius symbols are causing exceptions when converting csv blob file to string using toString(). I ran into this issue many time in the past but it's because of mysterious special characters that get inserted because of copy-paste. This time i inserted these symbols from excel insert tool box, it didn't work. I queried some data points with these symbols in my salesforce org and pasted in csv. It didn't work either. Please let me know your thoughts. Thanks.
Somehow, your users are inserting into their source spreadsheet a character that the spreadsheet can't encode as a valid UTF-8 character upon SAVE. SFDC only accepts UTF-8 characters. ASCII 00-FF maps to UTF-8 asis and the degree symbol
° is ASCII
B0. So you would expect to be fine.
But, if the user is copy-pasting the combined degree+C symbol
℃ (UTF-8 =
U+2103) into Excel and then saving as CSV, that is not in ASCII 00-FF and won't save as UTF-8 by Excel. Same issue with
℉ which is UTF-8
Who knew there were such UTF-8 characters? Cool.
MSFT Excel (through 2013, last version I have checked) will not save CSV files as UTF-8. Stackexchange discussion on VF uploads of CSV files here.
℉ does not save as
e2 84 89 but instead saves as
Open Office does have a save as CSV with UTF-8 encoding but your org may not use Open Office.
Google Docs does have a save as CSV with UTF-8 encoding but your org may not use Google Docs and anyway, as a cloud solution, having to save the file in Google Docs to your desktop and then upload to SFDC is a user bummer.