[SERVER-8353] Mongo shell in Windows running under Console2 complains wrongly about unicode font Created: 27/Jan/13  Updated: 20/Nov/13  Resolved: 04/Nov/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Gorm Eriksen Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

1. Install console2 (2.0.0 148 beta 32b is the one I tested) - http://sourceforge.net/projects/console/
2. Install mongo-win32 (2.2.2 64b is the one I tested)
3. Configure console2 to use Consolas (Edit-Settings->Appearance->Font
4. Start mongo
5. Type a unicode char e.g. æ ø or å

Participants:

 Description   

I have an issue with mongo shell reporting that a non-unicode font is used, even though console2 is configured to use consolas or Lucida Console

Note that it works well when running outside console2, so it's likely there the problem lay, but reporting it here first to see if there is anything that could be done differently in mongo. If not, I will take the bug to console2, but would appreciate any available help in reporting it.

When I type a unicode characther (e.g. æøå) this is what happens:

C:\Program Files\Console2>mongo
MongoDB shell version: 2.2.2
connecting to: test
>

Unicode text could not be correctly displayed.
Please change your console font to a Unicode font (e.g. Lucida Console).

├©
bye



 Comments   
Comment by Gorm Eriksen [ 28/Jan/13 ]

' What version of Windows are you running?

Windows 7 Ultimate 64b

' What language are you set for?

Using English windows

  • What keyboard layout are you using?

Norwegian

  • Do you have additional languages or keyboards installed?

Yes, English with US keyboard and Norwegian with Norwegian keyboard beneath, Norwegian configured as default.

  • Does the mongo shell handle Unicode correctly for you in the regular Windows Command Prompt window?

Yes

  • How are you providing your Unicode text?

I have tried both the special unicode chars and alt combination. Mongo shell exists at once.

  • If you type "chcp" at the Console2 command line prompt (cmd.exe), what does it say?

Active code page: 850

Same when I do it regular Windows Command Prompt.

Comment by Tad Marshall [ 28/Jan/13 ]
  1. What version of Windows are you running?
  2. What language are you set for?
  3. What keyboard layout are you using?
  4. Do you have additional languages or keyboards installed?
  5. Does the mongo shell handle Unicode correctly for you in the regular Windows Command Prompt window?
  6. How are you providing your Unicode text?
  7. If you type "chcp" at the Console2 command line prompt (cmd.exe), what does it say?
Comment by Gorm Eriksen [ 28/Jan/13 ]

I'm afraid I don't have more info. I tried with a freshly installed console2, and it exits here. However, I'm very glad you took a look at it, and if it works on your machine, considering it's a very edge case that one can easily work around, it's best to just close it. Thank you for your help!

Btw: this is how the test looks on my end. As soon as I write an unicode char it exit:

C:\temp\c2\Console2>ø æ å
'ø' is not recognized as an internal or external command,
operable program or batch file.

C:\temp\c2\Console2>mongo --nodb
MongoDB shell version: 2.2.2
>

Unicode text could not be correctly displayed.
Please change your console font to a Unicode font (e.g. Lucida Console).

æ
bye

Comment by Tad Marshall [ 27/Jan/13 ]

Hi Gorm,

I tried a quick test, and I can't reproduce your problem. I downloaded Console2 as Console-2.00b148-Beta_32bit.zip and MongoDB as mongodb-win32-x86_64-2.2.2.zip and tested in Windows 7 Home Premium 64-bit set to US English with Console2's default Courier New and with Consolas. Unicode is working for me.

I typed a few Unicode characters using Alt-+ and hex codes (00E1, 00E2, and others) and copied and pasted your text from the Jira ticket. No error message and the text shows up fine.

C:\> c:\bin\MongoDB\222\mongo --nodb
MongoDB shell version: 2.2.2
> print("non-ASCII: á â ã¡©")
non-ASCII: á â ã¡©
> // Type a unicode char e.g. æ ø or å
>

Can you provide additional information for me to reproduce your problem? Thanks!

Tad

Comment by Tad Marshall [ 27/Jan/13 ]

Hi Gorm,

Thanks for the report.

I had not heard of Console2, but since you provided the link to SourceForge I assume that this will be fully debuggable.

For reference, here is the code that is complaining: (excerpt from writeUtf8ToWindowsConsole() in src/mongo/util/text.cpp)

DWORD numberOfCharactersWritten;
BOOL success = WriteConsoleW( consoleHandle,
							  utf16Pointer,
							  numberOfCharactersThisPass,
							  &numberOfCharactersWritten,
							  NULL );
if ( 0 == success ) {
	DWORD dosError = GetLastError();
	static bool errorMessageShown = false;
	if ( ERROR_GEN_FAILURE == dosError ) {
		if ( ! errorMessageShown ) {
			std::cout << "\n---\nUnicode text could not be correctly displayed.\n"
					"Please change your console font to a Unicode font "
					"(e.g. Lucida Console).\n---\n" << std::endl;
			errorMessageShown = true;
		}
		// we can't display the text properly using a raster font,
		// but we can display the bits that will display ...
		_write( 1, utf8String, utf8StringSize );
	}
	return false;
}

As you can see, there is no actual checking for what font is set in your terminal (console) program; all we know for sure is that our attempt to use WriteConsoleW() failed with ERROR_GEN_FAILURE. In testing, this seemed to only happen when we tried to display non-ASCII test when an OEM font had been selected, which is why the error message says what it does.

In general, we really only support the Windows console. There are known problems with running in a Cygwin window, for example, and these are treated as low priority and generally "not our bug". Console2 may be in the same category, but we can see if there is a simple fix to either the mongo shell or Console2.

Tad

Generated at Thu Feb 08 03:17:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.