TIP 607: -failindex option for encoding convertto/convertfrom

Bounty program for improvements to Tcl and certain Tcl packages.
Author:         Jan Nijtmans <[email protected]>
State:          Draft
Type:           Project
Created:        30-Jul-2021
Keywords:       Tcl
Tcl-Version:    8.7


This TIP proposes to add a "-failindex" option to encoding convertto/convertfrom. The implementation depends on [601], the only change is that - when this option is provided - the error-location can be found in a variable in addition to being the last index of the -errorcode

-failindex option

The following proposal was initiated by a post by Andreas Leitgeb 2021-05-12 on the core list:

The command is extended by a -failindex option:

encoding convertfrom ?-failindex posvar? ?encoding? data
encoding convertto ?-failindex posvar? ?encoding? data

The distinct behaviour is as follows:

This specification is inspired by the already present option -failindex of the string is command.

Jan mentioned, that the implementation is not trivial, as the encoding ensemble is a partially compiled command. Nevertheless, an implementation is tried in the branch tip601-encoding-failindex.

Note: there was a side discussion within the thread if an incomplete multi-byte sequence is an error or not. Unfortunately, the required detail about the reporting method of an incomplete multi-byte sequence was not solved. So, it is considered as an error within this alternate solution.


This document has been placed in the public domain.