From 90de85d9f5905f92507b78f32a43e354a6181e2f Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Mon, 9 Apr 2001 13:24:30 +0000 Subject: create to_utf8 from po strings, use it for kdm message --- perl-install/c/stuff.xs.pm | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'perl-install/c') diff --git a/perl-install/c/stuff.xs.pm b/perl-install/c/stuff.xs.pm index 12d4c28a4..3fa08bc0a 100644 --- a/perl-install/c/stuff.xs.pm +++ b/perl-install/c/stuff.xs.pm @@ -455,7 +455,30 @@ from_utf8(s) char *buf = alloca(s_len + 10); /* 10 for safety, it should not be needed, utf8 is *always* bigger than a special encoding */ { char *ptr = buf; - int ptr_len = s_len; + int ptr_len = s_len + 10; + if ((iconv(cd, &s, &s_len, &ptr, &ptr_len)) != (size_t) (-1)) { + *ptr = 0; + RETVAL = buf; + } + } + iconv_close(cd); + } + OUTPUT: + RETVAL + +char * +to_utf8(charset, s) + char *charset + char *s + CODE: + iconv_t cd = iconv_open("utf-8", charset); + RETVAL = s; + if (cd != (iconv_t) (-1)) { + int s_len = strlen(RETVAL); + char *buf = alloca(2 * s_len + 10); /* 10 for safety, it should not be needed */ + { + char *ptr = buf; + int ptr_len = 2 * s_len + 10; if ((iconv(cd, &s, &s_len, &ptr, &ptr_len)) != (size_t) (-1)) { *ptr = 0; RETVAL = buf; -- cgit v1.2.1