Conversion between different character encodings. More...
#include <wchar.h>
Go to the source code of this file.
Functions | |
size_t | mutt_convert_file_from_to (FILE *fp, const struct Slist *fromcodes, const struct Slist *tocodes, char **fromcode, char **tocode, struct Content *info) |
Convert a file between encodings. | |
size_t | mutt_convert_file_to (FILE *fp, const char *fromcode, struct Slist const *const tocodes, int *tocode, struct Content *info) |
Change the encoding of a file. | |
struct Content * | mutt_get_content_info (const char *fname, struct Body *b, struct ConfigSubset *sub) |
Analyze file to determine MIME encoding to use. | |
void | mutt_update_content_info (struct Content *info, struct ContentState *s, char *buf, size_t buflen) |
Cache some info about an email. | |
Conversion between different character encodings.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file lib.h.
size_t mutt_convert_file_from_to | ( | FILE * | fp, |
const struct Slist * | fromcodes, | ||
const struct Slist * | tocodes, | ||
char ** | fromcode, | ||
char ** | tocode, | ||
struct Content * | info | ||
) |
Convert a file between encodings.
[in] | fp | File to read from |
[in] | fromcodes | Charsets to try converting FROM |
[in] | tocodes | Charsets to try converting TO |
[out] | fromcode | From charset selected |
[out] | tocode | To charset selected |
[out] | info | Info about the file |
num | Characters converted |
ICONV_ILLEGAL_SEQ | Error (as a size_t) |
Find the first of the fromcodes that gives a valid conversion and the best charset conversion of the file into one of the tocodes. If successful, set *fromcode and *tocode to dynamically allocated strings, set Content *info, and return the number of characters converted inexactly. If no conversion was possible, return -1.
Definition at line 215 of file convert.c.
size_t mutt_convert_file_to | ( | FILE * | fp, |
const char * | fromcode, | ||
struct Slist const *const | tocodes, | ||
int * | tocode, | ||
struct Content * | info | ||
) |
Change the encoding of a file.
[in] | fp | File to convert |
[in] | fromcode | Original encoding |
[in] | tocodes | List of target encodings |
[out] | tocode | Chosen encoding |
[out] | info | Encoding information |
-1 | Error, no conversion was possible |
>0 | Success, number of bytes converted |
Find the best charset conversion of the file from fromcode into one of the tocodes. If successful, set *tocode and Content *info and return the number of characters converted inexactly.
We convert via UTF-8 in order to avoid the condition -1(EINVAL), which would otherwise prevent us from knowing the number of inexact conversions. Where the candidate target charset is UTF-8 we avoid doing the second conversion because iconv_open("UTF-8", "UTF-8") fails with some libraries.
We assume that the output from iconv is never more than 4 times as long as the input for any pair of charsets we might be interested in.
Definition at line 64 of file convert.c.
struct Content * mutt_get_content_info | ( | const char * | fname, |
struct Body * | b, | ||
struct ConfigSubset * | sub | ||
) |
Analyze file to determine MIME encoding to use.
fname | File to examine |
b | Body to update |
sub | Config Subset |
ptr | Newly allocated Content |
Also set the body charset, sometimes, or not.
Definition at line 188 of file content_info.c.
void mutt_update_content_info | ( | struct Content * | info, |
struct ContentState * | s, | ||
char * | buf, | ||
size_t | buflen | ||
) |
Cache some info about an email.
info | Info about an Attachment |
s | Info about the Body of an email |
buf | Buffer for the result |
buflen | Length of the buffer |
Definition at line 49 of file content_info.c.