Add check for mbstring extension.

While there are try/catch blocks, they don't catch fatal errors. Therefore, the script breaks on servers running php 5+ but don'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){}`.