On 27/07/2010 8:32 PM, Michael Whapples wrote:
If translation fails outright, it will return an error, which will be converted into an exception. It shouldn't only translate part of the text and then return success unless outlen was too small. Nevertheless, I still think retrying like this is very nasty.I don't like the suggestion of try with one ratio, if translation fails retry with a larger ratio until it succeeds, is there a situation where translation may fail for another reason and how would such a system of setting the ratio catch that?
For a screen reader, I don't think you can necessarily make assumptions about the text you are displaying. Someone might be reading a document which is partially in a foreign language, for example.Setting the ratio to 8 times seems a bit drastic, and it would need to be higher if using 32-bit unicode, most of the time I doubt you would be going anywhere near that sort of ratio. I get the feeling the answer for what ratio is needed actually depends on what sort of translation is being done (IE. You are much more likely to need 8 times if only translating a character or two but you are probably going to be fine with 2 or 4 when doing longer strings of text).
So may be the answer is have the ratio at a level which should be fine for over 90% of uses
I'd probably default this to 2, which is what we use at present.
I think this is probably the best approach. I'm not "happy" with it - a Python programmer shouldn't have to be concerned with buffer lengths - but I don't really see a better way. If people are happy with this, I'll implement it ASAP, as this is a major problem for NVDA.but make the ratio value configurable so that the few who need something different can set it appropriately (IE. an application doing lots of small translations may have the line louis.bufferRatio = 8
An alternative is to always allocate a static buffer with a maximum size of 1 kb or something, but this seems pretty ugly and arbitrary to me.
Jamie -- James Teh Vice President NV Access Inc, ABN 61773362390 Email: jamie@xxxxxxxxxxxx Web site: http://www.nvaccess.org/ For a description of the software and to download it go to http://www.jjb-software.com