Edit

thodg/libiconv/man/iconvctl.3

Branch :

  • Show log

    Commit

  • Author : Bruno Haible
    Date : 2024-12-15 12:52:18
    Hash : 9f28054d
    Message : Implement the //NON_IDENTICAL_DISCARD suffix from POSIX:2024. * include/iconv.h.in (ICONV_GET_DISCARD_INVALID, ICONV_SET_DISCARD_INVALID, ICONV_GET_DISCARD_NON_IDENTICAL, ICONV_SET_DISCARD_NON_IDENTICAL): New macros. * lib/converters.h (struct conv_struct): Change type of discard_ilseq to 'unsigned int'. (DISCARD_INVALID, DISCARD_UNCONVERTIBLE): New macros. * lib/iconv.c (iconv_open, iconv_open_into): Change type of discard_ilseq to 'unsigned int'. (iconvctl): Implement ICONV_GET_DISCARD_INVALID, ICONV_SET_DISCARD_INVALID, ICONV_GET_DISCARD_NON_IDENTICAL, ICONV_SET_DISCARD_NON_IDENTICAL. Change the implementation of ICONV_GET_DISCARD_ILSEQ, ICONV_SET_DISCARD_ILSEQ to test/set both bits. * lib/iconv_open1.h: Update comment. Recognize //NON_IDENTICAL_DISCARD. * lib/iconv_open2.h: Update comment. * lib/loop_unicode.h (mb_to_uc_write_replacement): Test the DISCARD_UNCONVERTIBLE bit of discard_ilseq. (unicode_loop_convert): Test the respective bit of discard_ilseq. (unicode_loop_reset): Test the DISCARD_UNCONVERTIBLE bit of discard_ilseq. * lib/loop_wchar.h (wchar_from_loop_convert, wchar_to_loop_convert): Test the DISCARD_INVALID bit of discard_ilseq. * man/iconv_open.3: Mention the //NON_IDENTICAL_DISCARD suffix. Mark as conforming to POSIX:2024. * man/iconv.3: Likewise. * man/iconv_close.3: Mark as conforming to POSIX:2024. * man/iconv.1: Likewise. * man/iconvctl.3: Document ICONV_GET_DISCARD_INVALID, ICONV_SET_DISCARD_INVALID, ICONV_GET_DISCARD_NON_IDENTICAL, ICONV_SET_DISCARD_NON_IDENTICAL. Revise the description of ICONV_GET_DISCARD_ILSEQ, ICONV_SET_DISCARD_ILSEQ. * tests/test-discard.c (test_default, test_translit, test_ignore, test_ignore_translit): Test also the ICONV_GET_DISCARD_INVALID, ICONV_GET_DISCARD_NON_IDENTICAL accessors. (test_nid, test_nid_translit, test_invd, test_invd_translit): New functions. (main): Add test cases with //NON_IDENTICAL_DISCARD suffix. * NEWS: Mention the change.

  • man/iconvctl.3
  • .\" Copyright (c) Perry Rapp
    .\" Copyright (c) Free Software Foundation, Inc.
    .\"
    .\" This is free documentation; you can redistribute it and/or
    .\" modify it under the terms of the GNU General Public License as
    .\" published by the Free Software Foundation; either version 3 of
    .\" the License, or (at your option) any later version.
    .\"
    .\" References consulted:
    .\"   iconv.h
    .\"
    .TH ICONVCTL 3  "December 15, 2024" "GNU"
    .SH NAME
    iconvctl \- control iconv behavior
    .SH SYNOPSIS
    .nf
    .B #include <iconv.h>
    .sp
    .BI "int iconvctl (iconv_t " cd " , int " request ", void * " argument );
    .fi
    .SH DESCRIPTION
    The argument \fIcd\fP must be a conversion descriptor created using the
    function \fBiconv_open\fP.
    .PP
    \fBiconvctl\fP queries or adjusts the behavior of the \fBiconv\fP function,
    when invoked with the specified conversion descriptor, depending on the
    request value.
    .SH "REQUEST VALUES"
    The following are permissible values for the \fIrequest\fP parameter.
    .TP
    .B ICONV_TRIVIALP
    \fIargument\fP should be an \fBint *\fP which will receive 1 if the
    conversion is trivial, or 0 otherwise.
    .TP
    .B ICONV_GET_TRANSLITERATE
    \fIargument\fP should be an \fBint *\fP which will receive 1 if 
    transliteration is enabled in the conversion, or 0 otherwise.
    .TP
    .B ICONV_SET_TRANSLITERATE
    \fIargument\fP should be a \fBconst int *\fP, pointing to an \fBint\fP value.
    A non-zero value is used to enable transliteration in the conversion. A zero
    value disables it.
    .TP
    .B ICONV_GET_DISCARD_INVALID
    \fIargument\fP should be an \fBint *\fP which will receive 1 if "discard
    invalid multibyte sequence from the input and continue"
    is enabled in the conversion, or 0 otherwise.
    .TP
    .B ICONV_SET_DISCARD_INVALID
    \fIargument\fP should be a \fBconst int *\fP, pointing to an \fBint\fP value.
    A non-zero value is used to enable "discard
    invalid multibyte sequence from the input and continue"
    in the conversion. A zero value disables it.
    .TP
    .B ICONV_GET_DISCARD_NON_IDENTICAL
    \fIargument\fP should be an \fBint *\fP which will receive 1 if "discard
    character that cannot be represented in the target character set and continue"
    is enabled in the conversion, or 0 otherwise.
    .TP
    .B ICONV_SET_DISCARD_NON_IDENTICAL
    \fIargument\fP should be a \fBconst int *\fP, pointing to an \fBint\fP value.
    A non-zero value is used to enable "discard
    character that cannot be represented in the target character set and continue"
    in the conversion. A zero value disables it.
    .TP
    .B ICONV_GET_DISCARD_ILSEQ
    \fIargument\fP should be an \fBint *\fP which will receive 1 if both "discard"
    behaviours are enabled in the conversion, or 0 otherwise.
    .TP
    .B ICONV_SET_DISCARD_ILSEQ
    \fIargument\fP should be a \fBconst int *\fP, pointing to an \fBint\fP value.
    A non-zero value is used to enable both "discard" behaviours in the conversion.
    A zero value disables them.
    .TP
    .B ICONV_GET_FROM_SURFACE
    \fIargument\fP should be an \fBunsigned int *\fP which will receive the
    from-side (input side) surface of the conversion.
    .TP
    .B ICONV_SET_FROM_SURFACE
    \fIargument\fP should be a \fBconst unsigned int *\fP, pointing to an
    \fBunsigned int\fP value.  This value is installed as the from-side
    (input side) surface of the conversion.  The value is a bit mask.  Zero
    denotes no surface.  The value \fBICONV_SURFACE_EBCDIC_ZOS_UNIX\fP has
    an effect on EBCDIC encodings: The EBCDIC newline 0x15 will get mapped
    to LF instead of NEL.
    .TP
    .B ICONV_GET_TO_SURFACE
    \fIargument\fP should be an \fBunsigned int *\fP which will receive the
    to-side (output side) surface of the conversion.
    .TP
    .B ICONV_SET_TO_SURFACE
    \fIargument\fP should be a \fBconst unsigned int *\fP, pointing to an
    \fBunsigned int\fP value.  This value is installed as the to-side
    (output side) surface of the conversion.  The value is a bit mask.  Zero
    denotes no surface.  The value \fBICONV_SURFACE_EBCDIC_ZOS_UNIX\fP has
    an effect on EBCDIC encodings: LF, instead of NEL, will get mapped to
    the EBCDIC newline 0x15.
    .SH "RETURN VALUE"
    The \fBiconvctl\fP function returns 0 if it succeeds. In case of error, it sets
    \fBerrno\fP and returns \-1.
    .SH ERRORS
    The following errors can occur, among others:
    .TP
    .B EINVAL
    The request is invalid.
    .SH "CONFORMING TO"
    This function is implemented only in GNU libiconv and not in other \fBiconv\fP
    implementations. It is not backed by a standard. You can test for its presence
    through \fB(_LIBICONV_VERSION >= 0x0108)\fP.
    .SH "SEE ALSO"
    .BR iconv_open (3)
    .BR iconv (3)