Replace all non-ASCII bytes with "?" in case of broken UTF-8.

in some JS engines length is a function that will be called for every iteration of the loop, this trick initializes it just once