diff -ru binutils-040204.orig/binutils/windres.c binutils-040204/binutils/windres.c --- binutils-040204.orig/binutils/windres.c 2003-10-27 14:20:32.000000000 +0100 +++ binutils-040204/binutils/windres.c 2004-02-05 23:28:34.394860024 +0100 @@ -648,7 +648,8 @@ -l --language= Set language when reading rc file\n\ --use-temp-file Use a temporary file instead of popen to read\n\ the preprocessor output\n\ - --no-use-temp-file Use popen (default)\n")); + --no-use-temp-file Use popen (default)\n\ + --unicode Treat .rc strings as UTF-8 (#pragma still not supported)\n")); #ifdef YYDEBUG fprintf (stream, _("\ --yydebug Turn on parser debugging\n")); @@ -707,6 +708,7 @@ #define OPTION_USE_TEMP_FILE (OPTION_PREPROCESSOR + 1) #define OPTION_NO_USE_TEMP_FILE (OPTION_USE_TEMP_FILE + 1) #define OPTION_YYDEBUG (OPTION_NO_USE_TEMP_FILE + 1) +#define OPTION_UNICODE (OPTION_YYDEBUG+1) static const struct option long_options[] = { @@ -726,6 +728,7 @@ {"yydebug", no_argument, 0, OPTION_YYDEBUG}, {"version", no_argument, 0, 'V'}, {"help", no_argument, 0, 'h'}, + {"unicode", no_argument, 0, OPTION_UNICODE}, {0, no_argument, 0, 0} }; @@ -909,6 +912,9 @@ yydebug = 1; break; #endif + case OPTION_UNICODE: + conv_unicode = 1; + break; case 'h': case 'H': diff -ru binutils-040204.orig/binutils/winduni.c binutils-040204/binutils/winduni.c --- binutils-040204.orig/binutils/winduni.c 2003-09-14 14:20:17.000000000 +0200 +++ binutils-040204/binutils/winduni.c 2004-02-06 00:05:24.974800792 +0100 @@ -36,6 +36,13 @@ #include #endif +int conv_unicode=0; + +#ifndef _WIN32 +#include +static iconv_t conv=-1; +#endif + /* Convert an ASCII string to a unicode string. We just copy it, expanding chars to shorts, rather than doing something intelligent. */ @@ -43,25 +50,60 @@ unicode_from_ascii (int *length, unichar **unicode, const char *ascii) { int len; - const char *s; unsigned short *w; + char * tmp = NULL; + char * wsrc = ascii; + char * wdst; + int wsrclen; + int wdstlen; + int i; len = strlen (ascii); - if (length != NULL) - *length = len; +#ifndef _WIN32 + if (conv_unicode && conv == -1) { + conv=iconv_open("ucs-2le", "utf-8"); + } + + wsrclen = len; + wdstlen = len * 2; + + tmp = xmalloc(wdstlen); + wdst = tmp; + if (conv != -1) { + iconv(conv, &wsrc, &wsrclen, &wdst, &wdstlen); + iconv(conv, NULL, NULL, NULL, NULL); + len = (len * 2 - wdstlen) / 2; /* that many unicode chars */ + wdst = tmp; + } else { + for (i=0;i