String serialize and unserialize with limited sample charactors and specified replacements