I suspect this code might be easier to follow without the early returns.  It might be easier to reverse the logic so you hit utf32 stuff first - that way you don't need the additional check in the utf16 case).

pseudo code
```
if (contentLength >= 4 && content == 0x0000FEFF) // obv fixed up for proper comparisons.
  return "UTF-32BE";
if (contentLength >= 4 && content == 0xFFEF0000)
  return "UTF-32LE";
```
etc.