I'm glad you found that. I've been using this function essentially unmodified since writing it in 2011.
As agraham stated it could be done much more efficiently and is fairly incomplete when compared to the "C" function. I've also learned a lot more about variable type conversions – some of the conversions that I do are simply unnecessary.
But, it has worked for for me, so far. I hope it works for you.