File: iconv.cc

package info (click to toggle)
dcmtk 3.6.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 54,900 kB
  • sloc: cpp: 274,805; ansic: 47,345; makefile: 5,313; sh: 4,250; perl: 277; xml: 182; lex: 103
file content (52 lines) | stat: -rw-r--r-- 1,170 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 *  Copyright (C) 2018, OFFIS e.V.
 *  All rights reserved.  See COPYRIGHT file for details.
 *
 *  This software and supporting documentation were developed by
 *
 *    OFFIS e.V.
 *    R&D Division Health
 *    Escherweg 2
 *    D-26121 Oldenburg, Germany
 *
 *
 *  Module:  config
 *
 *  Author:  Jan Schlamelcher
 *
 *  Purpose: Analyze behavior of an iconv implementation.
 */

#include <iconv.h>
#include <stdio.h>

int main()
{
    char input[2] = { '\366', '\0' };
    char output[8];
    iconv_t i = iconv_open( "ASCII", "ISO-8859-1" );
    if( (iconv_t)-1 != i )
    {
        iconv( i, 0, 0, 0, 0 );
#ifdef LIBICONV_SECOND_ARGUMENT_CONST
        const
#endif
        char* in = input;
        char* out = output;
        size_t ins = 1;
        size_t outs = 8;
        const size_t result = iconv( i, &in, &ins, &out, &outs );
        iconv_close( i );
        if( ~(size_t)0 == result )
        {
            printf( "AbortTranscodingOnIllegalSequence" );
            return 0;
        }
        if( 8 == outs ) // output buffer not touched
        {
            printf( "DiscardIllegalSequences" );
            return 0;
        }
    }
    return 1;
}