Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Texts retrieved by FormatMessage on Windows #47

Closed
kubo opened this issue Nov 23, 2017 · 6 comments
Closed

Texts retrieved by FormatMessage on Windows #47

kubo opened this issue Nov 23, 2017 · 6 comments

Comments

@kubo
Copy link

kubo commented Nov 23, 2017

Some issues about FormatMessage used here on Windows
I might have to create separate issues. But some issues are related so I put all in one.

A potential bug

The 6th argument FormatMessageW is sizeof(wLoadError) but it should be sizeof(wLoadError)/sizeof(wchar_t) because the argument is the number of characters, not bytes, allocated for the 5th argument.

Message is incorrectly stripped on Japanese.

Trailing period and carriage return are stripped here. However, when the last character before carriage return is a multi-byte character, the character is broken. It should be stripped only when it is really period.

Message language

The error message retrieved by FormatMessageW depends on the OS language. Could you change the messages to English or add a compile-time option to change it?
The message is changed to English when the 4th argument is MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT).

Programs in the samples directory print garbled text in Japanese Windows command prompt when OCI.DLL is not found. If the message language is English, it isn't garbled.

Add error number to the message

When the message isn't changed to English, could you add the error number to the message?
For example when the error code is 126:

DPI-1047: 64-bit Oracle Client library cannot be loaded: Win32 error 126: "The specified module could not be found". See https://oracle.github.io/odpi/doc/installation.html#windows for help

When an issue is posted with a localized error message and you don't know the language, you cannot read the message. Moreover if it is garbled as messages in Japanese Windows command prompt, nobody read it. If the error number is included in the text, you can know the error as follows.

DPI-1047: 64-bit Oracle Client library cannot be loaded: Win32 error 126: "指定されたモジュールが見つかりません。". See https://oracle.github.io/odpi/doc/installation.html#windows for help
@anthony-tuininga
Copy link
Member

Since these are all in the same area of code it makes sense to deal with them at once. Thanks, @kubo.

@kubo
Copy link
Author

kubo commented Nov 28, 2017

The message is changed to English when the 4th argument is MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT).

Node.js uses MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US). If it fails, it uses 0, which equals MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT).
https://github.com/nodejs/node/blob/v9.2.0/deps/uv/src/win/dl.c#L104-L115

@anthony-tuininga
Copy link
Member

I've pushed a commit that should resolve these issues. Let me know. Thanks!

@kubo
Copy link
Author

kubo commented Dec 2, 2017

Thank you! It solved these issues.
I found a bug in the commit. Trailing period and carriage return are not stripped.
See 0fc9751#r25996466.

@anthony-tuininga
Copy link
Member

Thanks, @kubo. I have resolved that logic error as well. Not sure how I missed that!

@kubo
Copy link
Author

kubo commented Dec 5, 2017

Thanks!
All these issues were solved.

@kubo kubo closed this as completed Dec 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants