[Debburn-devel] Sample mini-iconv (Was: What can I assume about
libc?
Albert Cahalan
acahalan at gmail.com
Thu Oct 5 08:23:52 UTC 2006
On 10/4/06, Peter Samuelson <peter at p12n.org> wrote:
> I.e., the following code. It's completely untested, I just hacked it
> up tonight. Does it look like a useful API? Does anyone see any
> obvious (or not obvious) bugs?
By eyeball, it looks pretty good. The data types and
validation are especially nice. My two concerns are:
The "in" parameter is used in a way which prevents easy
use of an array. The user must create a pointer, often for
no use other than to satisfy the function being called.
The extra information is unlikely to be all that useful.
The "len" parameter might be a hazard. It seems to be
in terms of the number of input characters. Usually the
more important concern is the number of output bytes.
People may be tempted to use 2*n to allocate space
for n characters when the output is UTF-16, which would
allow for buffer overflows. Perhaps it is best to have both
input characters and output bytes specified.
Since these functions are memcpy-like (good IMHO),
some strlen-like functions may also be needed.
BTW, for the Windows port one might define UNICODE.
I believe this gets you all the OS interfaces in UTF-16.
Then you can go direct to Joliet from there, and you
don't need to care about 1-byte "OEM" cruft.
More information about the Debburn-devel
mailing list