Add check for mbstring extension.

While there are try/catch blocks with fallbacks to non-mbstring functions, they don't catch the fatal errors caused when PHP doesn't load the `mbstring` extension. 

The script now checks if the `mbstring` extension is loaded inside the `try{}`. If not, it will fallback to the non-mbstring function in the `catch(e){}`.