Also write empty CONT lines.
[gedcom-parse.git] / gedcom / encoding.c
index e0140b2f1dff7d32e24743748f10b42004d74f21..1cae728808f5c8dfd9f9cf6556f4c575a20e78dd 100644 (file)
 #include "gedcom_internal.h"
 #include "gedcom.h"
 #include "encoding.h"
+#include "encoding_state.h"
 #include "hash.h"
-#include "utf8.h"
+#include "utf8tools.h"
 
 #define ENCODING_CONF_FILE "gedcom.enc"
 #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" };
@@ -244,18 +244,13 @@ void init_encodings()
   }
 }
 
-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);
@@ -269,6 +264,7 @@ int open_conv_to_internal(const char* fromcode)
     if (to_int != NULL)
       cleanup_utf8_conversion(to_int);
     to_int = new_to_int;
+    set_read_encoding(fromcode, encoding);
   }
 
   return (new_to_int != NULL);