Re: [Libclc-developers] Re: clc_ultostr(3)
Status: Planning
Brought to you by:
augestad
|
From: Hallvard B F. <h.b...@us...> - 2003-03-20 19:25:40
|
Jan Engelhardt writes: >> 2) what to do if the buffer is not large enough: > > already said that... like snprintf(buf, 3, "%d", 234567); And as I said, snprintf doesn't _silently_ truncate like your latest clc_ultostr does. I want an error indication. Or a descision not to return an error, but I hope not. See below: >> Silently truncate, or generate a truncated string but return failure? >> If the latter, should it return NULL or should we change the return >> type so it returns the length of the string or -1 at truncation? (I >> think it's ugly to return NULL at failure but still have a meaningful >> output, but maybe that's just me?) >> 5) BTW, I'd like (2 <= base && base < 64): characters '0-9A-Za-z_=' >> or something. That's because I expect I'd usually use *printf to >> print normal numbers, but could use clc_ultostr with a large base >> when I want to generate textual IDs. Base 64 is nice for that, which >> is why I added "_" and "=" (two characters that hopefully have no >> special meaning in filesystems and shell commands). > > No, as we _may_ want to express 254 (decimal) in uh... (0x)FE as > well as (0x)fe. You mean to give a flag for uppercase/lowercase in the output as an argument to the function? Otherwise that is not relevant: The function will always produce uppercase when the base argument <= 36, the lowercase variant will only be produced for base > 36. -- Hallvard |