1/*---------------------------------------------------------------------------* 2 | PDFlib - A library for generating PDF on the fly | 3 +---------------------------------------------------------------------------+ 4 | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | 5 +---------------------------------------------------------------------------+ 6 | | 7 | This software is subject to the PDFlib license. It is NOT in the | 8 | public domain. Extended versions and commercial licenses are | 9 | available, please check http://www.pdflib.com. | 10 | | 11 *---------------------------------------------------------------------------*/ 12 13/* $Id: pc_unicode.h 14574 2005-10-29 16:27:43Z bonefish $ 14 * 15 * Unicode glyph name conversion routines 16 * 17 */ 18 19#ifndef PC_UNICODE_H 20#define PC_UNICODE_H 21 22#define PDC_MAX_UNICODE (int) 0x0000FFFF 23 24#define PDC_REPL_CHAR (int) 0x0000FFFD 25 26#define PDC_EURO_SIGN (pdc_ushort) 0x20AC 27 28/* The Unicode byte order mark (BOM) byte parts */ 29#define PDF_BOM0 0376 /* '\xFE' */ 30#define PDF_BOM1 0377 /* '\xFF' */ 31#define PDF_BOM2 0357 /* '\xEF' */ 32#define PDF_BOM3 0273 /* '\xBB' */ 33#define PDF_BOM4 0277 /* '\xBF' */ 34 35/* 36 * check whether the string is plain C or UTF16 unicode 37 * by looking for the BOM in big-endian or little-endian format resp. 38 * s must not be NULL. 39 */ 40#define pdc_is_utf16be_unicode(s) \ 41 (((pdc_byte *)(s))[0] == PDF_BOM0 && \ 42 ((pdc_byte *)(s))[1] == PDF_BOM1) 43 44#define pdc_is_utf16le_unicode(s) \ 45 (((pdc_byte *)(s))[0] == PDF_BOM1 && \ 46 ((pdc_byte *)(s))[1] == PDF_BOM0) 47 48#define pdc_is_unicode(s) pdc_is_utf16be_unicode(s) 49 50/* 51 * check whether the string is plain C or UTF8 unicode 52 * by looking for the BOM 53 * s must not be NULL. 54 */ 55#define pdc_is_utf8_unicode(s) \ 56 (((pdc_byte *)(s))[0] == PDF_BOM2 && \ 57 ((pdc_byte *)(s))[1] == PDF_BOM3 && \ 58 ((pdc_byte *)(s))[2] == PDF_BOM4) 59 60typedef struct 61{ 62 pdc_ushort code; 63 const char *glyphname; 64} pdc_glyph_tab; 65 66typedef enum 67{ 68 conversionOK, /* conversion successful */ 69 sourceExhausted, /* partial character in source, but hit end */ 70 targetExhausted, /* insuff. room in target for conversion */ 71 sourceIllegal /* source sequence is illegal/malformed */ 72} pdc_convers_result; 73 74typedef enum 75{ 76 strictConversion = 0, 77 lenientConversion 78} pdc_convers_flags; 79 80#define PDC_CONV_KEEPBYTES (1<<0) 81#define PDC_CONV_TRY7BYTES (1<<1) 82#define PDC_CONV_TRYBYTES (1<<2) 83#define PDC_CONV_WITHBOM (1<<3) 84#define PDC_CONV_NOBOM (1<<4) 85 86typedef enum 87{ 88 pdc_auto, 89 pdc_auto2, 90 pdc_bytes, 91 pdc_bytes2, 92 pdc_utf8, 93 pdc_utf16, 94 pdc_utf16be, 95 pdc_utf16le 96} pdc_text_format; 97 98pdc_ushort pdc_adobe2unicode(const char *name); 99 100const char *pdc_unicode2adobe(pdc_ushort uv); 101 102unsigned int pdc_name2sid(const char *name); 103 104const char *pdc_sid2name(unsigned int sid); 105 106pdc_bool pdc_is_std_charname(const char *name); 107 108pdc_ushort pdc_get_equi_unicode(pdc_ushort uv); 109 110int pdc_convert_string(pdc_core *pdc, 111 pdc_text_format inutf, pdc_encodingvector *inev, 112 pdc_byte *instring, int inlen, pdc_text_format *oututf_p, 113 pdc_encodingvector *outev, pdc_byte **outstring, int *outlen, int flags, 114 pdc_bool verbose); 115 116#endif /* PC_UNICODE_H */ 117