Show
Ignore:
Timestamp:
2000-06-08 11:36:13 (8 years ago)
Author:
Thomas Roessler <roessler@…>
Branch:
HEAD
Message:

Fix up the value returned by nl_langinfo(CODESET).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • charset.c

    r1879 r1885  
    3636 
    3737#ifndef EILSEQ 
    38 #define EILSEQ EINVAL 
     38# define EILSEQ EINVAL 
    3939#endif 
    4040 
     41#ifdef HAVE_LANGINFO_CODESET 
     42# include <langinfo.h> 
     43 
     44/*  
     45 * Try to convert nl_langinfo's return value to something we can 
     46 * use for MIME's purposes. 
     47 * 
     48 * Note that the algorithm used here is quite different from the 
     49 * one in mutt_canonical_charset.  
     50 */ 
     51 
     52void mutt_set_langinfo_charset (void) 
     53{ 
     54  char buff[LONG_STRING]; 
     55  char buff2[LONG_STRING]; 
     56  char *s, *d, *cp; 
     57   
     58  strfcpy (buff, nl_langinfo (CODESET), sizeof (buff)); 
     59  strfcpy (buff2, buff, sizeof (buff2)); 
     60   
     61  /* compactify the character set name returned */ 
     62  for (d = s = buff; *s; s++) 
     63  { 
     64    if (!strstr ("-_.", *s)) 
     65      *d++ = *s; 
     66  } 
     67  *d = '\0'; 
     68   
     69  /* look for common prefixes which may have been done wrong */ 
     70  if (!strncasecmp (buff, "iso8859", 7)) 
     71  { 
     72    snprintf (buff2, sizeof (buff2), "iso-8859-%s", buff + 7); 
     73    if ((cp = strchr (buff2, ':')))     /* strip :yyyy suffixes */ 
     74      *cp = '\0'; 
     75  } 
     76  else if (!strncasecmp (buff, "koi8", 4)) 
     77  { 
     78    snprintf (buff2, sizeof (buff2), "koi8-%s", buff + 4); 
     79  } 
     80  else if (!strncasecmp (buff, "windows", 7)) 
     81  { 
     82    snprintf (buff2, sizeof (buff2), "windows-%s" buff + 7); 
     83  } 
     84 
     85  /* fix the spelling */ 
     86  mutt_canonical_charset (buff, sizeof (buff), buff2); 
     87   
     88  /* finally, set $charset */ 
     89  Charset = safe_strdup (buff); 
     90} 
     91 
     92#endif 
    4193 
    4294void mutt_canonical_charset (char *dest, size_t dlen, const char *name)