1

I have an app which allows uploading spreadsheets in xls, xlsx and csv format. The data is later used at various client facing places. The people managing the data use various tools to create the spreadsheets, including mac/excel, win/excel, win/openoffice, linux/libreoffice...

The real problem is the mac/excel encoding, which creates some nasty looking strings. Is there any way to make sure the file content's encoding is valid utf-8?

My approach of just File.read(file.path).valid_encoding? checking works only for csv...

skaffman
  • 398,947
  • 96
  • 818
  • 769
schangli
  • 171
  • 7

1 Answers1

1

I would look into charlock_holmes, a gem which lets you easily detect and even attempt to transcode files based on their encoding.

Tim Park
  • 2,446
  • 2
  • 11
  • 13