Texts retrieved by FormatMessage on Windows · Issue #47 · oracle/odpi (original) (raw)
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