Closed youngquan closed 1 year ago
It could be mojibake although I have no idea how could you end up with a Unicode string in the exception object. The obvious suggestion is to try debugging this, i.e. put a breakpoint on the exception in the debugger and check what message it is constructed with.
Thanks for your reply.
I tried to change the exception type:
catch(soci::soci_error const& e)
{
cout << e.get_error_message() << std::endl;
cout << e.get_error_category() << endl;
cout << e.what() << std::endl;
cerr << "Error: " << e.what() << '\n';
}
Below are the outputs:
H��H�̉Hh�D$P��t�=l
7
H��H�̉Hh�D$P��t�=l
Error: H��H�̉Hh�D$P��t�=l
It seems the error category is unknown.
The excepiton seems to happen at when libmysql.dll is called. It is a runtime_error.
Here is a screenshot of the excption:
I also tried to specify the host and port in the connection string, however it still did not work.
You should be looking at the place the exception is thrown from, not where it's caught.
I tried to build soci from source, and all the tests of mysql passed. Then I tried to run the code above, using soci from vcpkg, however, the gibberish error never occured again. I can not reproduce this bug any longer. I have no idea of what is going on. Maybe the experimental feature of windows that using Unicode UTF-8 for worldwide language support is unstable. Anyway, sorry for the late reply and the unreproducible error.
I am using soci with cmake and vcpkg. I have already installed
soci[mysql]:windows-x64
from vcpkg.Here are some parts from
CMakeLists.txt
:Below is the code used for test:
I got these garbled outputs:
Does anybody have a cue?