Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Unicode

kfsone
New Contributor I
568 Views
I have the following line of code in a source file that sets the text of a dialog button:

m_okBtn->SetWindowTextW(L"") ; // Note 'L'

The Microsoft 2008 compiles this and produces an OK button with as the text.

Regardless of what encoding I save the file with (except UTF-16 which you don't support) the Intel compiler translates the character string and so results in a button with garbage in it ().

In order to work around it, I have to write the following code for Intel C++:

[cpp]void _setWindowItem(CWnd* wnd, const char* utf8Text)
{
  if ( wnd == NULL ) return ;
  wchar_t buffer[512] ;
  UTF8::ConvertChars(utf8Text, buffer, sizeof(utf8Text)) ;
  wnd->SetWindowTextW(buffer) ;
}

...

  _setWindowItem(m_okBtn, "") ; // Note: No L

[/cpp]
Any ideas what is causing this? Yes, the project is set to use Unicode character set.



0 Kudos
7 Replies
kfsone
New Contributor I
568 Views
Can't seem to find any means of telling ICC that a source file is not in ISO-8859-1. Anyone know if this is planned for a future feature?
0 Kudos
JenniferJ
Moderator
568 Views
icl does support unicode/ multi-byte.
which icl version are you using? is your program a MFC app or atl app? I'll create one simple testcase to find out.

Jennifer

0 Kudos
JenniferJ
Moderator
568 Views
I created a mfc dlg app, and set the dlg title to "L""", it works. But I have to save the .cpp file into Unicode.

is your .cpp file in unicode format?

0 Kudos
JenniferJ
Moderator
568 Views
I should have mentioned that I'm using the Parallel Composer beta, used following code:
[cpp]	SetWindowTextW(L"") ;  // Note 'L'
	SetDlgItemTextW(IDOK, L"");[/cpp]

You can get the Parallel Composer beta from http://www.intel.com/go/parallel/ .
0 Kudos
kfsone
New Contributor I
568 Views
I created a mfc dlg app, and set the dlg title to "L""", it works. But I have to save the .cpp file into Unicode.

is your .cpp file in unicode format?


Compiling with Intel C++ 11.0.066 [IA-32]... (Intel C++ Environment)

The cpp file and all of the h files were in UTF-8, I tried with and without the Microsoft leading bytes. I even tried UTF-16 and I've hex-dumped the files to verify that the characters are actually stored in the file as UTF-8 and I'm not seeing UTF-8 in the different editor scenarios I used (Visual Studio, XCode, CodeBlocks, KDevelop, Anjuta, VIM and VIM via putty configured to UTF-8) to make absolutely sure the characters were actually UTF-8.

[cpp]#include 

int main(int argc, char* argv[])
{
 const wchar_t* foo = L"" ;
 wprintf(L"%lsn", foo) ; 
}

[/cpp]
Produces the exact same result as doing:

[shell]$ echo  | iconv --from iso-8859-1 --to utf8

[/shell]
which is, to print:




0 Kudos
JenniferJ
Moderator
568 Views
Thanks for the simple testcase.
I saw the problem with UTF-8, Unicode. It only works when the file is ANSI. I'll submit a bug report with your testcase.

Thanks,
Jennifer
0 Kudos
JenniferJ
Moderator
568 Views
Quoting - kfsone
#include

int main(int argc, char* argv[])
{
const wchar_t* foo = L"" ;
wprintf(L"%lsn", foo) ;
}
did you try above code with VC? I got strange results so I'd like to see what you get.

Thanks,
Jennifer
0 Kudos
Reply