Dominik Seichter wrote:
> Hi,
> 
> Would it make sense to add a method 
> PdfString::GetCharacterLength() 
> {
>    return this->IsUnicode() ? this->GetUnicodeLength() : this->GetLength();
> }
> ?
> 
> I think this is what you need to always determine the correct character 
> length - assuming the PdfString contains no Utf8 encoded text.

Well, because of the UTF-16BE support PdfString can't really correctly
contain UTF-8 text; it'll do ToUnicode() conversions incorrectly by
assuming that its encoding is PdfDoc and transliterating the bytes.

I don't actually view that as a problem. The PDF Reference doesn't seem
to think that UTF-8 should be used in PDF strings, and if someone's
doing something weird they should not expect the PoDoFo API to support
them in that.

It's a pity we can't reliably detect and reject UTF-8. Oh well.

> Nontheless I do not think this is often needed. Users will have an own, more 
> powerful string class to do the actual work with and PdfString will only be 
> used when text is put into the PDF file.

True. PdfString isn't a useful generic string class and that's not its'
purpose. Nonetheless, this one is basically free.

> Despite this I would strongly vote 
> for adding the above method if you think it solves the problem.

It's a useful enough facility that a free inline is worth chucking in.
I'll do that.

> PS: The valgrind errors in the ConvertUTF*ToUTF* code are strange as the code 
> is taken almost directly from the unicode.org pages and should be well 
> tested. 

Maybe the real error originates in the test code? Or could it be padding
issues? I agree it's odd.

--
Craig Ringer

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to