我在C++ Builder中创建了一些C++类。我现在正在VCL表单应用程序中使用它们。我有一个加载文本文件并将字符串作为参数的函数。将unicode字符串转换为字符串
我正在使用openDialog控件浏览到该文件,然后打开它。
我的问题是这样的:openFialog的.filename属性是UnicodeString的形式,我的函数需要一个std :: string。我如何将unicode字符串转换为std :: string?
这里是我的代码:
OpenDialog1->Execute();
calCalendar.loadAppointmentsFromFile(OpenDialog1->FileName.t_str());
下面是函数的定义:
void loadAppointmentsFromFile(const std::string& stringFilename);
我收到以下错误:
[BCC32错误] Assessment2.cpp(39) :参数'stringFilename'中的E2342类型不匹配(想要'const std :: string &',得到'wchar_t *')
我能帮助解决这个问题吗?
你说的是ICU?然后http://userguide.icu-project.org/conversion/converters – 2012-09-24 04:03:14