Revision 5a6de4e7

View differences:

libavformat/mp3enc.c
77 77
    put_byte(s->pb, size       & 0x7f);
78 78
}
79 79

  
80
static int string_is_ascii(const uint8_t *str)
81
{
82
    while (*str && *str < 128) str++;
83
    return !*str;
84
}
85

  
80 86
/**
81 87
 * Write a text frame with one (normal frames) or two (TXXX frames) strings
82 88
 * according to encoding (only UTF-8 or UTF-16+BOM supported).
......
92 98
    if (url_open_dyn_buf(&dyn_buf) < 0)
93 99
        return AVERROR(ENOMEM);
94 100

  
101
    /* check if the strings are ASCII-only and use UTF16 only if
102
     * they're not */
103
    if (enc == ID3v2_ENCODING_UTF16BOM && string_is_ascii(str1) &&
104
        (!str2 || string_is_ascii(str2)))
105
        enc = ID3v2_ENCODING_ISO8859;
106

  
95 107
    put_byte(dyn_buf, enc);
96 108
    if (enc == ID3v2_ENCODING_UTF16BOM) {
97 109
        put_le16(dyn_buf, 0xFEFF);      /* BOM */

Also available in: Unified diff