Move string length and read to util class

I don't really like Util classes, but these two static methods
exist only to hide PHP braindamage.