#651 Characters broken for Unicode

Feature_requests
closed-fixed
gcc (462)
2004-09-24
2004-09-19
No

Windows XP SP2
gcc version 3.4.1
ld version 2.15.91 20040904
mingw-runtime 3.5
w32api 3.1

Compiling the code below return this error :
main.c:23:1: converting to execution character set:
Illegal byte sequence.

Replacing the '°' with a space ' ' works fine, but I
need some characters like this '°'... And the same code
compile fine on Visual C++ 7.1.3088 !

// begin sample code
#define UNICODE
#define _UNICODE
#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <commctrl.h>
#include <shellapi.h>

int main(void)
{
LPTSTR lpCmdLine = GetCommandLine();

TCHAR pom[MAX_PATH];
wsprintf(pom, TEXT("Arguments: [%s]"), lpCmdLine);
MessageBox(NULL, pom, TEXT("Information"),
MB_ICONINFORMATION | MB_OK);

INT argc;
LPTSTR* argv = CommandLineToArgvW(lpCmdLine, &argc);

INT i = 0;
while (i < argc)
{
wsprintf(pom, TEXT("Argument n°%i: [%s]"), i, argv[i]);
MessageBox(NULL, pom, TEXT("Information"),
MB_ICONINFORMATION | MB_OK);
++i;
}

return 0;
}
// end sample code

Discussion

  • Danny Smith

    Danny Smith - 2004-09-20

    Logged In: YES
    user_id=11494

    Confirmed.
    With 3.4.1 one workaround is:

    INT i = 0;
    TCHAR degree = 0xb0;
    while (i < argc)
    {
    wsprintf(pom, TEXT("Argument n%c %i: [%s]"), degree, i,
    argv[i]);
    MessageBox(NULL, pom, TEXT("Information"),
    MB_ICONINFORMATION | MB_OK);
    ++i;
    }

    In order to fix properly with current gcc sources is to add
    dependence on libiconv to allow LATIN1 narrow->wide charset
    conversion.

    With 3.4.2 built with libiconv, your testcase works with this
    command line switch -finput-charset=LATIN1

    Danny

     
  • Gabriel Linder

    Gabriel Linder - 2004-09-20

    Logged In: YES
    user_id=1121203

    All right, I'll wait for 3.4.2 so. But will it be built with
    libiconv by default, or shall I rebuild it ?

     
  • Gabriel Linder

    Gabriel Linder - 2004-09-22

    Logged In: YES
    user_id=1121203

    I have just tried the new GCC 3.4.2 version, and it works
    fine with -finput-charset=latin1. Many thanks ! ;-)

     
  • Danny Smith

    Danny Smith - 2004-09-24
    • status: open --> closed-fixed
     
  • Danny Smith

    Danny Smith - 2004-09-24

    Logged In: YES
    user_id=11494

    ReporterP confirms that bug is fixed with latest RC, so closing
    Danny

     

Log in to post a comment.