| 251 | */ |
| 252 | |
| 253 | void |
| 254 | _cupsSetLocale(char *argv[]) /* IO - Command-line arguments */ |
| 255 | { |
| 256 | int i; /* Looping var */ |
| 257 | char buffer[8192]; /* Command-line argument buffer */ |
| 258 | _cups_globals_t *cg; /* Global data */ |
| 259 | #ifdef LC_TIME |
| 260 | const char *lc_time; /* Current LC_TIME value */ |
| 261 | char new_lc_time[255], /* New LC_TIME value */ |
| 262 | *charset; /* Pointer to character set */ |
| 263 | #endif /* LC_TIME */ |
| 264 | |
| 265 | |
| 266 | /* |
| 267 | * Set the locale so that times, etc. are displayed properly. |
| 268 | * |
| 269 | * Unfortunately, while we need the localized time value, we *don't* |
| 270 | * want to use the localized charset for the time value, so we need |
| 271 | * to set LC_TIME to the locale name with .UTF-8 on the end (if |
| 272 | * the locale includes a character set specifier...) |
| 273 | */ |
| 274 | |
| 275 | setlocale(LC_ALL, ""); |
| 276 | |
| 277 | #ifdef LC_TIME |
| 278 | if ((lc_time = setlocale(LC_TIME, NULL)) == NULL) |
| 279 | lc_time = setlocale(LC_ALL, NULL); |
| 280 | |
| 281 | if (lc_time) |
| 282 | { |
| 283 | strlcpy(new_lc_time, lc_time, sizeof(new_lc_time)); |
| 284 | if ((charset = strchr(new_lc_time, '.')) == NULL) |
| 285 | charset = new_lc_time + strlen(new_lc_time); |
| 286 | |
| 287 | strlcpy(charset, ".UTF-8", sizeof(new_lc_time) - (size_t)(charset - new_lc_time)); |
| 288 | } |
| 289 | else |
| 290 | strlcpy(new_lc_time, "C", sizeof(new_lc_time)); |
| 291 | |
| 292 | setlocale(LC_TIME, new_lc_time); |
| 293 | #endif /* LC_TIME */ |
| 294 | |
| 295 | /* |
| 296 | * Initialize the default language info... |
| 297 | */ |
| 298 | |
| 299 | cg = _cupsGlobals(); |
| 300 | |
| 301 | if (!cg->lang_default) |
| 302 | cg->lang_default = cupsLangDefault(); |
| 303 | |
| 304 | /* |
| 305 | * Transcode the command-line arguments from the locale charset to |
| 306 | * UTF-8... |
| 307 | */ |
| 308 | |
| 309 | if (cg->lang_default->encoding != CUPS_US_ASCII && |
| 310 | cg->lang_default->encoding != CUPS_UTF8) |