mirror of
https://github.com/transmission/transmission
synced 2025-01-31 03:12:44 +00:00
(libT) #1491: json floats decimal separator depends on language settings
This commit is contained in:
parent
b8e9ef54fe
commit
bc51d19c0d
1 changed files with 9 additions and 0 deletions
|
@ -17,6 +17,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
#include <event.h> /* evbuffer */
|
||||
|
||||
#include "ConvertUTF.h"
|
||||
|
@ -707,8 +709,15 @@ tr_bencDictAddDouble( tr_benc * dict,
|
|||
double d )
|
||||
{
|
||||
char buf[128];
|
||||
char * locale;
|
||||
|
||||
/* the json spec requires a '.' decimal point regardless of locale */
|
||||
locale = tr_strdup( setlocale ( LC_NUMERIC, NULL ) );
|
||||
setlocale( LC_NUMERIC, "POSIX" );
|
||||
tr_snprintf( buf, sizeof( buf ), "%f", d );
|
||||
setlocale( LC_NUMERIC, locale );
|
||||
tr_free( locale );
|
||||
|
||||
return tr_bencDictAddStr( dict, key, buf );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue