From 62899aa21f4cc8029325c74d2d016d7554590ccb Mon Sep 17 00:00:00 2001 From: oetiker Date: Mon, 13 Jun 2005 12:56:11 +0000 Subject: [PATCH] fall back to assuming latin1 encoding if mbtowchar conversion fails git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@637 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_gfx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rrd_gfx.c b/src/rrd_gfx.c index 44f668b..478d70c 100644 --- a/src/rrd_gfx.c +++ b/src/rrd_gfx.c @@ -386,7 +386,11 @@ gfx_string gfx_string_create(gfx_canvas_t *canvas, FT_Face face,const char *text cstr = malloc(sizeof(wchar_t) * clen); /* yes we are allocating probably too much here, I know */ string->count=mbstowcs(cstr,text,clen); if ( string->count == -1){ - string->count=mbstowcs(cstr,"Enc-Err",6); + /* conversion did not work, so lets fall back to just use what we got */ + string->count=clen-1; + for(n=0;text[n] != '\0';n++){ + cstr[n]=text[n]; + } } #else char *cstr = strdup(text); -- 2.11.0