void do_locale_check() { #if ADOBE_PLATFORM_WIN typedef std::numpunct<char> numpunct_type; static std::string old_locale_ident; std::string new_locale_ident(get_locale_tidbit(LOCALE_SENGLANGUAGE) << "_" << get_locale_tidbit(LOCALE_SENGCOUNTRY)); if (old_locale_ident == new_locale_ident) return; old_locale_ident = new_locale_ident; // get the important stuff to push to the dictionary std::locale locale(new_locale_ident.c_str()); const numpunct_type& numpunct(std::use_facet<numpunct_type>(locale)); char sep(numpunct.thousands_sep()); std::string thousands_separator(&sep, 1); char decimal(numpunct.decimal_point()); std::string decimal_point(&decimal, 1); // finally push the important stuff into the dictionary dictionary_t new_locale_data; new_locale_data.insert(std::make_pair(key_locale_identifier, new_locale_ident)); new_locale_data.insert(std::make_pair(key_locale_decimal_point, decimal_point)); new_locale_data.insert(std::make_pair(key_locale_thousands_separator, thousands_separator)); adobe::implementation::signal_locale_change(new_locale_data); #endif }
static char *flt(char *str, double num, int size, int precision, char fmt, int flags) { char tmp[80]; char c, sign; int n, i; // Left align means no zero padding if (flags & LEFT) flags &= ~ZEROPAD; // Determine padding and sign char c = (flags & ZEROPAD) ? '0' : ' '; sign = 0; if (flags & SIGN) { if (num < 0.0) { sign = '-'; num = -num; size--; } else if (flags & PLUS) { sign = '+'; size--; } else if (flags & SPACE) { sign = ' '; size--; } } // Compute the precision value if (precision < 0) precision = 6; // Default precision: 6 // Convert floating point number to text parse_float(num, tmp, fmt, precision); if ((flags & HEX_PREP) && precision == 0) decimal_point(tmp); if (fmt == 'g' && !(flags & HEX_PREP)) cropzeros(tmp); n = strnlen(tmp,256); // Output number with alignment and padding size -= n; if (!(flags & (ZEROPAD | LEFT))) while (size-- > 0) *str++ = ' '; if (sign) *str++ = sign; if (!(flags & LEFT)) while (size-- > 0) *str++ = c; for (i = 0; i < n; i++) *str++ = tmp[i]; while (size-- > 0) *str++ = ' '; return str; }