pdf-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pdf-devel] Patch for FS#116


From: Aleksander Morgado
Subject: Re: [pdf-devel] Patch for FS#116
Date: Sun, 18 Apr 2010 11:51:26 +0200

Hey gerel,

> Here is a patch for FS#116. New pdf_text_get_printable.
> Aleks, tell me if this was what you meant.

Just one comment, below. Thanks!

>  
> +const pdf_char_t *
> +pdf_text_get_printable (pdf_text_t text)
> +{
> +  pdf_size_t size;
> +
> +  if (text->printable != NULL){
> +    if (text->modified == PDF_FALSE){
> +      return text->printable;
> +    }else{
> +      pdf_dealloc(text->printable);
> +    }
> +  }
> +
> +#ifdef PDF_HOST_WIN32
> +  pdf_text_get_unicode(&text->printable, &size, text, PDF_TEXT_UTF16_HE,
> +                       PDF_TEXT_UNICODE_NO_OPTION);

Should be PDF_TEXT_UTF16_LE here instead of _HE (well, in this case it
would work for Windows machines, are they are already LE, but better to
explicitly state it). And instead of PDF_TEXT_UNICODE_NO_OPTION, the
PDF_TEXT_UNICODE_WITH_NUL_SUFFIX option should be passed, so that the
string is NUL-terminated (2-NUL-bytes in the case of UTF16).

> +#else
> +  pdf_text_get_unicode(&text->printable, &size, text, PDF_TEXT_UTF8,
> +                       PDF_TEXT_UNICODE_NO_OPTION);
> +#endif /*PDF_HOST_WIN32*/
> +
> +  text->modified = PDF_FALSE;
> +
> +  return text->printable;
> +}
>  

Same as above, instead of PDF_TEXT_UNICODE_NO_OPTION, the
PDF_TEXT_UNICODE_WITH_NUL_SUFFIX option should be passed, so that the
string is NUL-terminated (1-NUL-byte in the case of UTF8).


If the printable strings are not NUL-terminated they cannot be used in
the printf-like functions.


Cheers!

-- 
Aleksander





reply via email to

[Prev in Thread] Current Thread [Next in Thread]