Reputation: 3446
I maintain an application written in Borland C++ 6. This app is using SQLite database.
I am now extending it, so it can be used by unprivileged users, and so I had to move the database file to the home user directory. Unfortunately some of users have Polish national characters in their names, such as ą,ć,ę and some more. The system codepage is cp1250, but SQLite requires me to pass an utf-8 encoded path.
So, basicly I need to convert a cp1250 encoded path:
String path = "c:\documents and settings\User Name like Zażółć gęślą Jaźń\Application Data\...\MyDb.sqlite"
to utf-8, and then pass it to sqlite with path.c_str();
Does C++ builder have any class to convert charsets, or should I just map the short set of polish national character codes to their utf-8 representations?
Upvotes: 1
Views: 4658
Reputation: 32635
I couldn't find the documentation for C++ Builder (the links on Borland's page seem to be broken), but from what I recall, you can directly convert from AnsiString to WideString.
Once you have a UTF-16 string, you can use WideCharToMultiByte Windows function, passing CP_UTF8 as a parameter.
Upvotes: 2