Are you not assuming that the "utf32" specified in the function name is LE/BE agnostic?  Before the function explicitly used utf32LE.  We don't run on any BE platforms any longer (well, not officially) but this might potentially be an issue if whatever is passing code into this function happens to be utf32LE regardless of platform.