ANSIString performance improvements

ANSIString now does its best to reuse the character/code tables it generates so that it does not have to recalculate them from scratch each time.