Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
exhu is currently offline  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 Go to previous messageGo to next message
mirek is currently offline  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
Re: [BUG] CommandLine() returns non-unicode arguments [message #15245 is a reply to message #15238] Fri, 11 April 2008 14:58 Go to previous messageGo to next message
exhu is currently offline  exhu
Messages: 12
Registered: April 2008
Location: Belarus
Promising Member
What I am sure about is that the command line MUST accept Unicode (int argc, WCHAR argv[]). This is a requirement for my utilities which must take file names via command line. And some files may be named using national characters.

But as for the console output, things are quite different here... I wouldn't change Cout() right now.
Re: [BUG] CommandLine() returns non-unicode arguments [message #15277 is a reply to message #15245] Tue, 15 April 2008 07:07 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
exhu wrote on Fri, 11 April 2008 08:58

What I am sure about is that the command line MUST accept Unicode (int argc, WCHAR argv[]). This is a requirement for my utilities which must take file names via command line. And some files may be named using national characters.

But as for the console output, things are quite different here... I wouldn't change Cout() right now.


Well, we still have to maintain win98 compatibility... that is why we are using ANSI mode. Anyway, it looks like we can fix the issue using GetCommandLineW here.

Mirek
Previous Topic: Convert upp Font size to LOGFONT size
Next Topic: Time should contain msecs too
Goto Forum:
  


Current Time: Sun Apr 28 21:56:45 CEST 2024

Total time taken to generate the page: 0.02614 seconds