diff --git a/include/zsv/api.h b/include/zsv/api.h index 014c9b83..9bc05640 100644 --- a/include/zsv/api.h +++ b/include/zsv/api.h @@ -258,6 +258,11 @@ ZSV_EXPORT size_t zsv_scanned_length(zsv_parser); */ ZSV_EXPORT size_t zsv_cum_scanned_length(zsv_parser parser); +/** + * @return number of raw bytes scanned from the beginning to the end of this row + */ +ZSV_EXPORT size_t zsv_row_length_raw_bytes(zsv_parser parser); + /** * Check the quoted status of the last cell that was read. This function is only * applicable when called from within a cell_handler() callback. Furthermore, this diff --git a/src/zsv.c b/src/zsv.c index a728f707..10809d58 100644 --- a/src/zsv.c +++ b/src/zsv.c @@ -446,7 +446,14 @@ size_t zsv_scanned_length(zsv_parser parser) { ZSV_EXPORT size_t zsv_cum_scanned_length(zsv_parser parser) { - return parser->cum_scanned_length + parser->scanned_length + (parser->had_bom ? strlen(ZSV_BOM) : 0); + return parser->cum_scanned_length + + (parser->finished ? 0 : parser->scanned_length) + + (parser->had_bom ? strlen(ZSV_BOM) : 0); +} + +ZSV_EXPORT +size_t zsv_row_length_raw_bytes(zsv_parser parser) { + return parser->scanned_length - parser->row_start; } /**