[Gdal-dev] locale handling in GDAL

Ray Gardener rayg at daylongraphics.com
Mon Mar 6 14:24:04 EST 2006


> I have tried implementing something like sprintf() before and it is
> hard to do in an efficient (much less correct) manner.  How does other
> software handle this?  It must come up all the time!

The job might not be as hard as canonical sprintf() if GDAL is only 
using a subset of the possible features (e.g., printing only strings, 
chars, ints and floats).

Another way is to use printf/sprintf only for strings, and make your own 
printing routines that return strings. This complicates the call syntax 
but can be implemented easier. e.g.:

char* printnum(int n, char* psz)
{
    // go through digits of n and place into psz.
}

void foo(int n)
{
    char sz[30];
    sprintf(pszMsg, "Answer is: %s", printnum(n, sz));
}


Ray



More information about the Gdal-dev mailing list