Changeset 7166


Ignore:
Timestamp:
Nov 27, 2008, 6:35:26 PM (10 years ago)
Author:
charles
Message:

(libT) #1491: json floats decimal separator depends on language settings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bencode.c

    r6944 r7166  
    1717#include <stdlib.h>
    1818#include <string.h>
     19
     20#include <locale.h>
    1921
    2022#include <event.h> /* evbuffer */
     
    708710{
    709711    char buf[128];
    710 
     712    char * locale;
     713
     714    /* the json spec requires a '.' decimal point regardless of locale */
     715    locale = tr_strdup( setlocale ( LC_NUMERIC, NULL ) );
     716    setlocale( LC_NUMERIC, "POSIX" );
    711717    tr_snprintf( buf, sizeof( buf ), "%f", d );
     718    setlocale( LC_NUMERIC, locale );
     719    tr_free( locale );
     720
    712721    return tr_bencDictAddStr( dict, key, buf );
    713722}
Note: See TracChangeset for help on using the changeset viewer.