[liblouis-liblouisxml] Re: Python bindings and output buffer size for lou_translate*

  • From: Timothy Lee <timothy.ty.lee@xxxxxxxxx>
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Thu, 05 Aug 2010 09:29:42 +0800

 Dear all,

On 08/04/2010 09:21 AM, James Teh wrote:
The original reason that this arose is now somewhat mitigated by the new undefined opcode, but nevertheless, I think it should probably be resolved. So:

On 27/07/2010 8:32 PM, Michael Whapples wrote:
Firstly I have seen later messages in this thread and agree that it
would not be natural for python programs to have to specify the buffer
sizes.
Michael, how does jlouis handle this inlen/outlen situation? John, how about your JNI bindings? As I understand it, it's not really natural to specify maximum buffer sizes in either language.
Can I throw in my 2 cents worth? I've been using liblouis under C, and to overcome this problem, I use a loop to invoke lou_translate() with an increasingly large buffer. It starts with a factor of 2, and aborts when the ratio reaches 10. To determine whether outlen was insufficient, I check whether the returned outlen is the same as the buffer size.

The down side of this method is that it can be time consuming, because it invokes lou_translate() multiple times.

Regards,
Timothy Lee
For a description of the software and to download it go to
http://www.jjb-software.com

Other related posts: