~ubuntu-branches/ubuntu/jaunty/ghostscript/jaunty-updates

« back to all changes in this revision

Viewing changes to base/ConvertUTF.h

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-01-20 16:40:45 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120164045-lnfhi0n30o5lwhwa
Tags: 8.64.dfsg.1~svn9377-0ubuntu1
* New upstream release (SVN rev 9377)
   o Fixes many bugs concerning PDF rendering, to make the PDF printing
     workflow correctly working.
   o Fixes long-standing bugs in many drivers, like input paper tray and
     duplex options not working for the built-in PCL 4, 5, 5c, 5e, and
     6/XL drivers, PDF input not working for bjc600, bjc800, and cups
     output devices, several options not working and uninitialized
     memory with cups output device.
   o Merged nearly all patches of the Ubuntu and Debian packages upstream.
   o Fixes LP: #317810, LP: #314439, LP: #314018.
* debian/patches/03_libpaper_support.dpatch,
  debian/patches/11_gs-cjk_font_glyph_handling_fix.dpatch,
  debian/patches/12_gs-cjk_vertical_writing_metrics_fix.dpatch,
  debian/patches/13_gs-cjk_cjkps_examples.dpatch,
  debian/patches/20_bbox_segv_fix.dpatch,
  debian/patches/21_brother_7x0_gdi_fix.dpatch,
  debian/patches/22_epsn_margin_workaround.dpatch,
  debian/patches/24_gs_man_fix.dpatch,
  debian/patches/25_toolbin_insecure_tmp_usage_fix.dpatch,
  debian/patches/26_assorted_script_fixes.dpatch,
  debian/patches/29_gs_css_fix.dpatch,
  debian/patches/30_ps2pdf_man_improvement.dpatch,
  debian/patches/31_fix-gc-sigbus.dpatch,
  debian/patches/34_ftbfs-on-hurd-fix.dpatch,
  debian/patches/35_disable_libcairo.dpatch,
  debian/patches/38_pxl-duplex.dpatch,
  debian/patches/39_pxl-resolution.dpatch,
  debian/patches/42_gs-init-ps-delaybind-fix.dpatch,
  debian/patches/45_bjc600-bjc800-pdf-input.dpatch,
  debian/patches/48_cups-output-device-pdf-duplex-uninitialized-memory-fix.dpatch,
  debian/patches/50_lips4-floating-point-exception.dpatch,
  debian/patches/52_cups-device-logging.dpatch,
  debian/patches/55_pcl-input-slot-fix.dpatch,
  debian/patches/57_pxl-input-slot-fix.dpatch,
  debian/patches/60_pxl-cups-driver-pdf.dpatch,
  debian/patches/62_onebitcmyk-pdf.dpatch,
  debian/patches/65_too-big-temp-files-1.dpatch,
  debian/patches/67_too-big-temp-files-2.dpatch,
  debian/patches/70_take-into-account-data-in-stream-buffer-before-refill.dpatch:
  Removed, applied upstream.
* debian/patches/01_docdir_fix_for_debian.dpatch,
  debian/patches/02_gs_man_fix_debian.dpatch,
  debian/patches/01_docdir-fix-for-debian.dpatch,
  debian/patches/02_docdir-fix-for-debian.dpatch: Renamed patches to
  make merging with Debian easier.
* debian/patches/32_improve-handling-of-media-size-changes-from-gv.dpatch, 
  debian/patches/33_bad-params-to-xinitimage-on-large-bitmaps.dpatch:
  regenerated for new source directory structure.
* debian/rules: Corrected paths to remove cidfmap (it is in Resource/Init/
  in GS 8.64) and to install headers (source paths are psi/ and base/ now).
* debian/rules: Remove all fontmaps, as DeFoMa replaces them.
* debian/local/pdftoraster/pdftoraster.c,
  debian/local/pdftoraster/pdftoraster.convs, debian/rules: Removed
  added pdftoraster filter and use the one which comes with Ghostscript.
* debian/ghostscript.links: s/8.63/8.64/

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2001-2004 Unicode, Inc.
 
3
 * 
 
4
 * Disclaimer
 
5
 * 
 
6
 * This source code is provided as is by Unicode, Inc. No claims are
 
7
 * made as to fitness for any particular purpose. No warranties of any
 
8
 * kind are expressed or implied. The recipient agrees to determine
 
9
 * applicability of information provided. If this file has been
 
10
 * purchased on magnetic or optical media from Unicode, Inc., the
 
11
 * sole remedy for any claim will be exchange of defective media
 
12
 * within 90 days of receipt.
 
13
 * 
 
14
 * Limitations on Rights to Redistribute This Code
 
15
 * 
 
16
 * Unicode, Inc. hereby grants the right to freely use the information
 
17
 * supplied in this file in the creation of products supporting the
 
18
 * Unicode Standard, and to make copies of this file in any form
 
19
 * for internal or external distribution as long as this notice
 
20
 * remains attached.
 
21
 */
 
22
 
 
23
/* $Id: ConvertUTF.h 8405 2007-11-22 02:46:59Z giles $*/
 
24
 
 
25
#ifndef ConvertUTF_INCLUDED
 
26
#define ConvertUTF_INCLUDED
 
27
 
 
28
/* ---------------------------------------------------------------------
 
29
 
 
30
    Conversions between UTF32, UTF-16, and UTF-8.  Header file.
 
31
 
 
32
    Several funtions are included here, forming a complete set of
 
33
    conversions between the three formats.  UTF-7 is not included
 
34
    here, but is handled in a separate source file.
 
35
 
 
36
    Each of these routines takes pointers to input buffers and output
 
37
    buffers.  The input buffers are const.
 
38
 
 
39
    Each routine converts the text between *sourceStart and sourceEnd,
 
40
    putting the result into the buffer between *targetStart and
 
41
    targetEnd. Note: the end pointers are *after* the last item: e.g. 
 
42
    *(sourceEnd - 1) is the last item.
 
43
 
 
44
    The return result indicates whether the conversion was successful,
 
45
    and if not, whether the problem was in the source or target buffers.
 
46
    (Only the first encountered problem is indicated.)
 
47
 
 
48
    After the conversion, *sourceStart and *targetStart are both
 
49
    updated to point to the end of last text successfully converted in
 
50
    the respective buffers.
 
51
 
 
52
    Input parameters:
 
53
        sourceStart - pointer to a pointer to the source buffer.
 
54
                The contents of this are modified on return so that
 
55
                it points at the next thing to be converted.
 
56
        targetStart - similarly, pointer to pointer to the target buffer.
 
57
        sourceEnd, targetEnd - respectively pointers to the ends of the
 
58
                two buffers, for overflow checking only.
 
59
 
 
60
    These conversion functions take a ConversionFlags argument. When this
 
61
    flag is set to strict, both irregular sequences and isolated surrogates
 
62
    will cause an error.  When the flag is set to lenient, both irregular
 
63
    sequences and isolated surrogates are converted.
 
64
 
 
65
    Whether the flag is strict or lenient, all illegal sequences will cause
 
66
    an error return. This includes sequences such as: <F4 90 80 80>, <C0 80>,
 
67
    or <A0> in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code
 
68
    must check for illegal sequences.
 
69
 
 
70
    When the flag is set to lenient, characters over 0x10FFFF are converted
 
71
    to the replacement character; otherwise (when the flag is set to strict)
 
72
    they constitute an error.
 
73
 
 
74
    Output parameters:
 
75
        The value "sourceIllegal" is returned from some routines if the input
 
76
        sequence is malformed.  When "sourceIllegal" is returned, the source
 
77
        value will point to the illegal value that caused the problem. E.g.,
 
78
        in UTF-8 when a sequence is malformed, it points to the start of the
 
79
        malformed sequence.  
 
80
 
 
81
    Author: Mark E. Davis, 1994.
 
82
    Rev History: Rick McGowan, fixes & updates May 2001.
 
83
                 Fixes & updates, Sept 2001.
 
84
 
 
85
------------------------------------------------------------------------ */
 
86
 
 
87
/* ---------------------------------------------------------------------
 
88
    The following 4 definitions are compiler-specific.
 
89
    The C standard does not guarantee that wchar_t has at least
 
90
    16 bits, so wchar_t is no less portable than unsigned short!
 
91
    All should be unsigned values to avoid sign extension during
 
92
    bit mask & shift operations.
 
93
------------------------------------------------------------------------ */
 
94
 
 
95
typedef unsigned long   UTF32;  /* at least 32 bits */
 
96
typedef unsigned short  UTF16;  /* at least 16 bits */
 
97
typedef unsigned char   UTF8;   /* typically 8 bits */
 
98
typedef unsigned char   Boolean; /* 0 or 1 */
 
99
 
 
100
/* Some fundamental constants */
 
101
#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
 
102
#define UNI_MAX_BMP (UTF32)0x0000FFFF
 
103
#define UNI_MAX_UTF16 (UTF32)0x0010FFFF
 
104
#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF
 
105
#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF
 
106
 
 
107
typedef enum {
 
108
        conversionOK,           /* conversion successful */
 
109
        sourceExhausted,        /* partial character in source, but hit end */
 
110
        targetExhausted,        /* insuff. room in target for conversion */
 
111
        sourceIllegal           /* source sequence is illegal/malformed */
 
112
} ConversionResult;
 
113
 
 
114
typedef enum {
 
115
        strictConversion = 0,
 
116
        lenientConversion
 
117
} ConversionFlags;
 
118
 
 
119
/* This is for C++ and does no harm in C */
 
120
#ifdef __cplusplus
 
121
extern "C" {
 
122
#endif
 
123
 
 
124
ConversionResult ConvertUTF8toUTF16 (
 
125
                const UTF8** sourceStart, const UTF8* sourceEnd, 
 
126
                UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
 
127
 
 
128
ConversionResult ConvertUTF16toUTF8 (
 
129
                const UTF16** sourceStart, const UTF16* sourceEnd, 
 
130
                UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
 
131
                
 
132
ConversionResult ConvertUTF8toUTF32 (
 
133
                const UTF8** sourceStart, const UTF8* sourceEnd, 
 
134
                UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
 
135
 
 
136
ConversionResult ConvertUTF32toUTF8 (
 
137
                const UTF32** sourceStart, const UTF32* sourceEnd, 
 
138
                UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
 
139
                
 
140
ConversionResult ConvertUTF16toUTF32 (
 
141
                const UTF16** sourceStart, const UTF16* sourceEnd, 
 
142
                UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
 
143
 
 
144
ConversionResult ConvertUTF32toUTF16 (
 
145
                const UTF32** sourceStart, const UTF32* sourceEnd, 
 
146
                UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
 
147
 
 
148
Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd);
 
149
 
 
150
#ifdef __cplusplus
 
151
}
 
152
#endif
 
153
 
 
154
/* --------------------------------------------------------------------- */
 
155
 
 
156
#endif /* ConvertUTF_INCLUDED */