unsigned i, j;
/*@@@ yuck, should do this with a varargs function or something: */
-#define PPR if(filename)flac_printf("%s:",filename);
+#define PPR if(filename) { if(raw) printf("%s:",filename); else flac_printf("%s:",filename); }
PPR; printf("METADATA block #%u\n", block_number);
PPR; printf(" type: %u (%s)\n", (unsigned)block->type, block->type < FLAC__METADATA_TYPE_UNDEFINED? FLAC__MetadataTypeString[block->type] : "UNKNOWN");
PPR; printf(" is last: %s\n", block->is_last? "true":"false");
ok = remove_vc_firstfield(filename, block, operation->argument.vc_field_name.value, needs_write);
break;
case OP__SET_VC_FIELD:
+#ifdef _WIN32 /* do not convert anything or things will break */
+ ok = set_vc_field(filename, block, &operation->argument.vc_field, needs_write, true);
+#else
ok = set_vc_field(filename, block, &operation->argument.vc_field, needs_write, raw);
+#endif
break;
case OP__IMPORT_VC_FROM:
ok = import_vc_from(filename, block, &operation->argument.filename, needs_write, raw);
}
else {
FLAC__bool needs_free = false;
-#ifdef _WIN32 /* do not convert anything or things will break */
entry.entry = (FLAC__byte *)field->field;
-#else
if(raw) {
entry.entry = (FLAC__byte *)field->field;
}
flac_fprintf(stderr, "%s: ERROR: converting comment '%s' to UTF-8\n", filename, field->field);
return false;
}
-#endif
entry.length = strlen((const char *)entry.entry);
if(!FLAC__format_vorbiscomment_entry_is_legal(entry.entry, entry.length)) {
if(needs_free)
{
if(0 != entry->entry) {
if(filename)
- fprintf(f, "%s:", filename);
+ flac_fprintf(f, "%s:", filename);
if(!raw) {
/*
* WATCHOUT: comments that contain an embedded null will
* be truncated by utf_decode().
*/
+#ifdef _WIN32 /* if we are outputting to console, we need to use proper print functions to show unicode characters */
+ if (f == stdout || f == stderr) {
+ flac_fprintf(f, "%s", entry->entry);
+ } else {
+#endif
char *converted;
if(utf8_decode((const char *)entry->entry, &converted) >= 0) {
else {
(void) local_fwrite(entry->entry, 1, entry->length, f);
}
+#ifdef _WIN32
+ }
+#endif
}
else {
(void) local_fwrite(entry->entry, 1, entry->length, f);
return -1;
}
- chars = WideCharToMultiByte(GetConsoleCP(), WC_COMPOSITECHECK, unicode,
+ chars = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode,
-1, NULL, 0, NULL, NULL);
if(chars < 0) /* underflow check */
return -1;
}
- err = WideCharToMultiByte(GetConsoleCP(), WC_COMPOSITECHECK, unicode,
+ err = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode,
-1, *to, chars, NULL, NULL);
if(err != chars)
{