Changeset 7b1d048 for util.c


Ignore:
Timestamp:
Dec 29, 2007, 2:55:43 AM (13 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
2febcae
Parents:
6201646
Message:
first pass at outbound zephyr -> iso-8859-1 sanitizing.
Not that we can input anything other than ascii yet...

The plan is that for a given field, we'll try to convert to iso-8859-1.
If that doesn't work, use utf-8.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • util.c

    r6201646 r7b1d048  
    812812  }
    813813}
     814/* Attempts to convert 'in' to ISO-8859-1. Returns that if possible,
     815   else returns UTF-8.
     816 */
     817char * owl_get_iso_8859_1_if_possible(char *in)
     818{
     819  char *out;
     820  if (g_utf8_validate(in, -1, NULL)) {
     821    out = g_convert(in, -1,
     822                    "ISO-8859-1", "UTF-8",
     823                    NULL, NULL, NULL);
     824    if (!out) {
     825      out = owl_strdup(in);
     826    }
     827  }
     828  else {
     829    out = owl_strdup("");
     830  }
     831  return out;
     832}
    814833
    815834/**************************************************************************/
Note: See TracChangeset for help on using the changeset viewer.