#include "gedcom_internal.h"
#include "gedcom.h"
#include "encoding.h"
+#include "encoding_state.h"
#include "hash.h"
#include "utf8tools.h"
#define GCONV_SEARCH_PATH "GCONV_PATH"
#define MAXBUF 255
-static Encoding the_enc = ONE_BYTE;
static hash_t *encodings = NULL;
const char* charwidth_string[] = { "1", "2_HILO", "2_LOHI" };
key = (char*)malloc(strlen(gedcom_n) + strlen(charwidth_string[enc]) + 3);
if (key) {
+ char* sp_pos = NULL;
+ while ((sp_pos = strchr(gedcom_n, ' ')) != NULL) {
+ *sp_pos = '_';
+ }
/* sprintf is safe here (malloc'ed before) */
sprintf(key, "%s(%s)", gedcom_n, charwidth_string[enc]);
}
}
-void set_encoding_width(Encoding enc)
-{
- the_enc = enc;
-}
-
static convert_t to_int = NULL;
static char* error_value = "<error>";
int open_conv_to_internal(const char* fromcode)
{
convert_t new_to_int = NULL;
- const char *encoding = get_encoding(fromcode, the_enc);
+ const char *encoding = get_encoding(fromcode, read_encoding.width);
if (encoding != NULL) {
new_to_int = initialize_utf8_conversion(encoding, 1);
if (to_int != NULL)
cleanup_utf8_conversion(to_int);
to_int = new_to_int;
+ set_read_encoding(fromcode, encoding);
}
return (new_to_int != NULL);