view sidutil.h @ 341:fe061ead51cc

Perform character set conversion after item formatting step instead of before it. This should remedy the potential issue of formatting not taking UTF8 multibyte into account, as our formatting unfortunately does not support multibyte encoding. This way the data should stay in ISO-8859-1 format just up to outputting it.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 13 Jan 2020 16:29:47 +0200
parents f3ba2ba894b1
children a6153837c138
line wrap: on
line source

/*
 * SIDLib common utility functions
 * Programmed and designed by Matti 'ccr' Hämäläinen <ccr@tnsp.org>
 * (C) Copyright 2014-2020 Tecnic Software productions (TNSP)
 */
#ifndef SIDUTIL_H
#define SIDUTIL_H 1

#include "th_util.h"
#ifdef HAVE_ICONV
#    include <iconv.h>
#endif


#ifdef __cplusplus
extern "C" {
#endif


//
// Some constants
//

// HVSC documents directory
#define SIDUTIL_HVSC_DOCUMENTS   "DOCUMENTS"

// Songlengths database filename prefix (.md5|.txt appended)
#define SIDUTIL_SLDB_FILEBASE    "Songlengths"

// STIL database file
#define SIDUTIL_STILDB_FILENAME  "STIL.txt"


enum
{
    TH_LANG_UTF8,
    TH_LANG_ISO88591,
    TH_LANG_CP850,
    TH_LANG_CP437,
};


//
// Typedefs
//
typedef struct
{
    BOOL enabled;
    char *outLang;
#ifdef HAVE_ICONV
    iconv_t iconvCtx;
#else
    int outLangID;
#endif
} SIDUtilChConvCtx;


//
// Functions
//
void           sidutil_print_license(void);

char *         sidutil_escape_string(const char *str, const char *escchars);
void           sidutil_print_string_escaped(FILE *outFile, const char *str);

const char *   sidutil_strip_hvsc_path(const char *hvscPath, const char *filename);
char *         sidutil_check_hvsc_file(const char *hvscPath, const char *filebase, const char *fext);

char *         sidutil_chconv_convert(SIDUtilChConvCtx *ctx, const char *src);

int            sidutil_chconv_init(SIDUtilChConvCtx *ctx, const char *outLang);
void           sidutil_chconv_close(SIDUtilChConvCtx *ctx);


#ifdef __cplusplus
}
#endif
#endif // SIDUTIL_H