dlugolecki.net.pl
Dziennik
Polecane
Software
projects
/
gedcom-parse.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Character encoding (UTF-8 to locale) example and use in standalone.c.
[gedcom-parse.git]
/
standalone.c
diff --git
a/standalone.c
b/standalone.c
index 70a3ac17f80a8bb1a0f60ef811a560a6cfa735e1..9c8dc15d2130188daf58d18bc945fa2b93036af0 100644
(file)
--- a/
standalone.c
+++ b/
standalone.c
@@
-25,7
+25,10
@@
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <locale.h>
+#include <errno.h>
#include "gedcom.h"
#include "gedcom.h"
+#include "utf8-locale.h"
#define OUTFILE "testgedcom.out"
FILE* outfile = NULL;
#define OUTFILE "testgedcom.out"
FILE* outfile = NULL;
@@
-168,8
+171,11
@@
Gedcom_ctxt source_date_start(Gedcom_ctxt parent, int level, char *tag,
void default_cb(Gedcom_ctxt ctxt, int level, char *tag, char *raw_value,
int tag_value)
{
void default_cb(Gedcom_ctxt ctxt, int level, char *tag, char *raw_value,
int tag_value)
{
+ char *converted = NULL;
+ if (raw_value)
+ converted = convert_utf8_to_locale(raw_value);
output(0, "== %d %s (%d) %s (ctxt is %d)\n",
output(0, "== %d %s (%d) %s (ctxt is %d)\n",
- level, tag, tag_value,
raw_value
, (int)ctxt);
+ level, tag, tag_value,
converted
, (int)ctxt);
}
void subscribe_callbacks()
}
void subscribe_callbacks()
@@
-252,6
+258,7
@@
int main(int argc, char* argv[])
exit(1);
}
exit(1);
}
+ setlocale(LC_ALL, "");
gedcom_set_debug_level(debug_level, NULL);
gedcom_set_compat_handling(compat_enabled);
gedcom_set_error_handling(mech);
gedcom_set_debug_level(debug_level, NULL);
gedcom_set_compat_handling(compat_enabled);
gedcom_set_error_handling(mech);