[Live-devel] sprintf and radix char.

Derk-Jan Hartman hartman at videolan.org
Tue Aug 23 13:48:39 PDT 2005


Hello Ross,

fenrir ran into an interesting problem. RTSPClient.cpp uses sprintf  
to create the Range: header. However the radix character used when  
printing a float with sprintf (as createRangeString uses), is locale  
dependent. However Range needs to use . as radix character.

Therefore it should be wrapped in something like this.

#ifdef USE_LOCALE
     prev_locale = dupstring(setlocale(LC_NUMERIC, NULL));
     setlocale(LC_NUMERIC, "POSIX");
#endif

sprintf call

#ifdef USE_LOCALE
     if (prev_locale) setlocale(LC_NUMERIC, prev_locale);
#endif

I gather there is probably more then one area where this might go  
wrong. perhaps you should create your own sdotprintf for this purpose  
of printing floats to strings that are passed around.

DJ


More information about the live-devel mailing list