Differences From Artifact [0c8db08aa1]:
- File
src/OFSystemInfo.h
— part of check-in
[6dff0f5922]
at
2017-01-07 02:34:39
on branch trunk
— Always use "." for the decimal point
This is achieved by replacing the locale's decimal point with "." after
formatting and replacing "." with the locale's decimal point before
parsing.To still use the decimal point from the locale for formatting, the new
flag "," is introduced to formats. This is useful for just printing a
string to the user that is not saved to a file or sent via a network.While this is an ugly hack, there is no better way to do this other than
implementing the functionality of printf and strtod myself, as POSIX
does not specify versions of these that take a locale as an argument.
While this is a lot of work and error-prone, I will most likely end up
doing this eventually.This commit also enables the locale in OFApplication to notice when
things break. As a nice side effect, ofhttp now uses the locale's
decimal point in its user interface. (user: js, size: 5384) [annotate] [blame] [check-ins using]
To Artifact [c797094656]:
- File
src/OFSystemInfo.h
— part of check-in
[d6de0a1b71]
at
2017-01-08 03:45:05
on branch trunk
— Parse locale to get {language,territory,encoding}
Yes, there is really nothing to query this.
Yes, locales in C and POSIX are broken way beyond repair. (user: js, size: 5795) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | + (size_t)numberOfCPUs; /*! * @brief Returns the native 8-bit string encoding of the operating system. * * This is useful to encode strings correctly for passing them to operating * system calls. * * @return The native 8-bit string encoding of the operating system */ + (of_string_encoding_t)native8BitEncoding; /*! * @brief Returns the decimal point in the system's locale. * * @return The decimal point in the system's locale */ + (OFString*)decimalPoint; | > > > > > > > > > > > > > > > > > > > > | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | + (size_t)numberOfCPUs; /*! * @brief Returns the native 8-bit string encoding of the operating system. * * This is useful to encode strings correctly for passing them to operating * system calls. * * If the native 8-bit encoding is unknown, UTF-8 is assumed. * * @return The native 8-bit string encoding of the operating system */ + (of_string_encoding_t)native8BitEncoding; /*! * @brief Returns the language of the locale. * * If the language is unknown, nil is returned. * * @return The language of the locale. */ + (OFString*)language; /*! * @brief Returns the territory of the locale. * * If the territory is unknown, nil is returned. * * @return The territory of the locale. */ + (OFString*)territory; /*! * @brief Returns the decimal point in the system's locale. * * @return The decimal point in the system's locale */ + (OFString*)decimalPoint; |
︙ | ︙ |