Prevent showing warning about encoding wrongly when making ID3v1 fields
Due to the fallthrough the warning would be printed in any case when using UTF-8 and not only if the BOM is actually written (as there are non-ASCII characters). This problem became apparent when using the tageditor's CLI with `--id3-init-on-create` to create an ID3v1 tag from ID3v2. Of course it doesn't help if there are actually non-ASCII characters present.
This commit is contained in:
parent
f39e8b4d8c
commit
2fda0a505d
|
@ -313,12 +313,12 @@ void Id3v1Tag::writeValue(const TagValue &value, size_t length, char *buffer, os
|
|||
// handle encoding
|
||||
auto *valueStart = buffer;
|
||||
auto valueLength = length;
|
||||
auto hasProblematicEncoding = false;
|
||||
switch (value.dataEncoding()) {
|
||||
case TagTextEncoding::Latin1:
|
||||
case TagTextEncoding::Unspecified:
|
||||
break;
|
||||
case TagTextEncoding::Utf8:
|
||||
// write
|
||||
// write UTF-8 BOM if the value contains non-ASCII characters
|
||||
for (const auto c : valueAsString) {
|
||||
if ((c & 0x80) == 0) {
|
||||
continue;
|
||||
|
@ -328,10 +328,14 @@ void Id3v1Tag::writeValue(const TagValue &value, size_t length, char *buffer, os
|
|||
buffer[2] = static_cast<char>(0xBF);
|
||||
valueStart += 3;
|
||||
valueLength -= 3;
|
||||
hasProblematicEncoding = true;
|
||||
break;
|
||||
}
|
||||
[[fallthrough]];
|
||||
break;
|
||||
default:
|
||||
hasProblematicEncoding = true;
|
||||
}
|
||||
if (hasProblematicEncoding) {
|
||||
diag.emplace_back(DiagLevel::Warning, "The used encoding is unlikely to be supported by other software.", "making ID3v1 tag field");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue