JafSoft Support Forums  
  Products:
AscToHTM (text to HTML) / AscToPDF (text to PDF) / AscToRTF (text to RTF) / Detagger (HTML to text and markup removal) 

 
  Forum options:
Forum Index  Register  Login  Search  FAQ  Log Out
Member options:
My Profile  Inbox  Member List  Address Book  My Subscription  My Forums 
 
 

Note: Some forums require a login other than "Guest" in order to post messages and replies


API: Why am I getting BUFFERTOOSMALL as the result?

 
Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums > [Hints and Tips] > Frequently Asked Questions > API: Why am I getting BUFFERTOOSMALL as the result? Page: [1]
Login
Message << Older Topic   Newer Topic >
API: Why am I getting BUFFERTOOSMALL as the result? - 5/12/2006 12:01:17 AM   
Jaf

 

Posts: 70
Joined: 2/1/2006
Status: offline
When calling the API you sometimes get a result of OK, but an "inner result" of R_BUFFERTOOSMALL.  When this happens the returned string is blank.

What this is telling you is that the fixed-size buffer you passed to the API to receive the result is in fact too small for the results generated.  When this happens the API returns the status R_BUFFERTOOSMALL, but is still holding onto the result internally in it's own buffer.

You can access this result (without having to re-do the conversion) by taking the following steps

- call CONVERTER_GetOutCharArraySize to determine what size buffer is required
- allocate a new buffer of that size
- make a call to CONVERTER_GetOutCharArray_Ptr passing the new buffer and it's size to retrieve the stored results.

A good rule of thumb is that the output buffer used to receive the results should be at least equal to the size of the input buffer, so in most cases allocating an output buffer equal in size to the input string should be more than adequate.  That is because in most cases when converting to text the output is smaller than the input.  However this isn't always the case as sometimes table layouts cause the resulting text to be padded out.

This issue is discussed in the API documentation in the section "Checking the conversion results when using (char *) pointers" where there is also some sample code.  See

   http://www.jafsoft.com/doco/api_manual.html#checking_the_conversion_result__che02407

I have recently improved the VB example to include this type of logic (though it isn't yet in the current online samples).  I will probably update the C# sample as well.  If you need sample code, feel free to email me to see if I have any available.
Post #: 1
Page:   [1]
All Forums > [Hints and Tips] > Frequently Asked Questions > API: Why am I getting BUFFERTOOSMALL as the result? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts