check index before writing to result->chars While here, configure with --enable-ucs4 to unbreak python3 bindings (reported by Mike Burns, thanks!)