Home » U++ Library support » U++ Core » [BUG] CommandLine() returns non-unicode arguments
[BUG] CommandLine() returns non-unicode arguments [message #15238] |
Fri, 11 April 2008 10:05 |
exhu
Messages: 12 Registered: April 2008 Location: Belarus
|
Promising Member |
|
|
Tested with 2007.1 win, MSVC 2005, WinXP SP2.
UPDATE: use windows console with Lucida Console font (that which is unicode-aware).
run as:
"mycon.exe schußbändig"
result:
"shu?bandig"
(the string is to contain umlauts or other symbols not in current ANSI encoding, try russian letters etc. if your current code page in WinXP contains umlauts).
Program source:
#include <iostream>
CONSOLE_APP_MAIN
{
const Vector<String> & cmdline = CommandLine();
for(Vector<String>::ConstIterator i = cmdline.Begin();i != cmdline.End();++i) {
std::cout << (*i).Begin() << std::endl;
}
}
NOTE: cout actually is not a proper class to use here, but if the U++ uses wide char win32 api then the produced string would be utf-8 or so and not the word with question mark and simply "a" instead of "a umlaut"...
[Updated on: Fri, 11 April 2008 10:07] Report message to a moderator
|
|
|
Re: [BUG] CommandLine() returns non-unicode arguments [message #15242 is a reply to message #15238] |
Fri, 11 April 2008 14:24 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
exhu wrote on Fri, 11 April 2008 04:05 | Tested with 2007.1 win, MSVC 2005, WinXP SP2.
UPDATE: use windows console with Lucida Console font (that which is unicode-aware).
run as:
"mycon.exe schußbändig"
result:
"shu?bandig"
(the string is to contain umlauts or other symbols not in current ANSI encoding, try russian letters etc. if your current code page in WinXP contains umlauts).
Program source:
#include <iostream>
CONSOLE_APP_MAIN
{
const Vector<String> & cmdline = CommandLine();
for(Vector<String>::ConstIterator i = cmdline.Begin();i != cmdline.End();++i) {
std::cout << (*i).Begin() << std::endl;
}
}
NOTE: cout actually is not a proper class to use here, but if the U++ uses wide char win32 api then the produced string would be utf-8 or so and not the word with question mark and simply "a" instead of "a umlaut"...
|
U++ uses wide char win32 api when available and mostly for filenames only... Internally, it can work in several encodings, utf8 being the recommended one.
Anyway, this is interesting problem, something not considered before... Commandline actually is used "as is", in ANSI version, without any conversions. The same is true for Cout.
Still, something is wrong with console output - input (commandline) seems to be OK, but output is wrong. But maybe you know more about these issues...
INteresting question is also what is the correct solution. Should Cout perform on-the-fly encoding coversion?
Mirek
|
|
|
|
|
Goto Forum:
Current Time: Sun Apr 28 21:56:45 CEST 2024
Total time taken to generate the page: 0.02614 seconds
|