Fixed incorrect format function not taking into account strange strings

issue #580
Oops, a bit too strange characters were generated by a too large range..
Fixed a lot of incorrect string loops

issue #580
Implemented a correct version of wrap to assure support for full unicode