re-wrote length function to deal with 4 byte utf characters in a JTR correct manner