using charAt inside sprintf. Dealing strings as array is not supported in earlier ie