Handling Character Sets in the Dropbox API for Android

This all feels slightly ridiculous, but getting iOS apps and Android apps to talk to each other via Dropbox is complicated considerably by the issue of Unicode and Character Sets. For anybody who hadn’t realised – computer science is plagued by the effects of the fall, and the legacy of the Tower of Babel is keenly felt. Computers simply can’t agree on how to talk to each other, they can’t even agree on how to speak French – some computers representing characters in a character encoding like UTF8 that uses one byte per letter unless more are needed, and others encoding in UTF16 that uses two bytes per letter unless more are needed.

It would appear that the iOS Dropbox API is saving files out in UTF16 (at least in my app!) whereas Java (and therefore the Android Dropbox API) naturally reads things in UTF8, causing problems!

It feels like total overkill, but in the end I discovered this handy little Java library that can guess what character encoding has been used for a given string: juniversalchardet