diff options
Diffstat (limited to 'source/pdf/pdf-parse.c')
-rw-r--r-- | source/pdf/pdf-parse.c | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/source/pdf/pdf-parse.c b/source/pdf/pdf-parse.c index 104b117d..f4075c5a 100644 --- a/source/pdf/pdf-parse.c +++ b/source/pdf/pdf-parse.c @@ -208,106 +208,6 @@ pdf_load_stream_or_string_as_utf8(fz_context *ctx, pdf_obj *src) return pdf_to_utf8(ctx, src); } -/* Convert Unicode/PdfDocEncoding string into ucs-2 */ -unsigned short * -pdf_to_ucs2(fz_context *ctx, pdf_obj *src) -{ - unsigned char *srcptr = (unsigned char *) pdf_to_str_buf(ctx, src); - unsigned short *dstptr, *dst; - int srclen = pdf_to_str_len(ctx, src); - int i; - - if (srclen >= 2 && srcptr[0] == 254 && srcptr[1] == 255) - { - dstptr = dst = fz_malloc_array(ctx, (srclen - 2) / 2 + 1, sizeof(short)); - for (i = 2; i + 1 < srclen; i += 2) - *dstptr++ = srcptr[i] << 8 | srcptr[i+1]; - } - else if (srclen >= 2 && srcptr[0] == 255 && srcptr[1] == 254) - { - dstptr = dst = fz_malloc_array(ctx, (srclen - 2) / 2 + 1, sizeof(short)); - for (i = 2; i + 1 < srclen; i += 2) - *dstptr++ = srcptr[i] | srcptr[i+1] << 8; - } - else - { - dstptr = dst = fz_malloc_array(ctx, srclen + 1, sizeof(short)); - for (i = 0; i < srclen; i++) - *dstptr++ = pdf_doc_encoding[srcptr[i]]; - } - - *dstptr = '\0'; - return dst; -} - -/* allow conversion to UCS-2 without the need for a fz_context */ -/* (buffer must be at least (fz_to_str_len(src) + 1) * 2 bytes in size) */ -void -pdf_to_ucs2_buf(fz_context *ctx, unsigned short *buffer, pdf_obj *src) -{ - unsigned char *srcptr = (unsigned char *) pdf_to_str_buf(ctx, src); - unsigned short *dstptr = buffer; - int srclen = pdf_to_str_len(ctx, src); - int i; - - if (srclen >= 2 && srcptr[0] == 254 && srcptr[1] == 255) - { - for (i = 2; i + 1 < srclen; i += 2) - *dstptr++ = srcptr[i] << 8 | srcptr[i+1]; - } - else if (srclen >= 2 && srcptr[0] == 255 && srcptr[1] == 254) - { - for (i = 2; i + 1 < srclen; i += 2) - *dstptr++ = srcptr[i] | srcptr[i+1] << 8; - } - else - { - for (i = 0; i < srclen; i++) - *dstptr++ = pdf_doc_encoding[srcptr[i]]; - } - - *dstptr = '\0'; -} - -/* Convert UCS-2 string into PdfDocEncoding for authentication */ -char * -pdf_from_ucs2(fz_context *ctx, unsigned short *src) -{ - int i, j, len; - char *docstr; - - len = 0; - while (src[len]) - len++; - - docstr = fz_malloc(ctx, len + 1); - - for (i = 0; i < len; i++) - { - /* shortcut: check if the character has the same code point in both encodings */ - if (0 < src[i] && src[i] < 256 && pdf_doc_encoding[src[i]] == src[i]) { - docstr[i] = src[i]; - continue; - } - - /* search through pdf_docencoding for the character's code point */ - for (j = 0; j < 256; j++) - if (pdf_doc_encoding[j] == src[i]) - break; - docstr[i] = j; - - /* fail, if a character can't be encoded */ - if (!docstr[i]) - { - fz_free(ctx, docstr); - return NULL; - } - } - docstr[len] = '\0'; - - return docstr; -} - pdf_obj * pdf_to_utf8_name(fz_context *ctx, pdf_obj *src) { |