c++ - 在 C++ 中将 std::string 转换为 Unicode 字符串

标签 c++ string unicode c++builder

我有一个问题。我需要将字符串类型转换为 unicode。 我知道这样的方法

string.c_str();

但它在我的代码中不起作用。

我有功能

void modify(string infstring, string* poststring)

我需要在备忘录中显示 infstring。像一个

Form1->Memo1->Lines->Add("some text "+infstring.c_str()+" some text");

但编译器告诉我“E2085 无效指针添加”

我该如何解决我的问题?

最佳答案

Form1->Memo1->Lines->Add("some text "+infstring.c_str()+" some text");

应该是

Form1->Memo1->Lines->Add(("some text "+infstring+" some text").c_str());

即您将字符串文字添加到 std::string 然后 使用 c_str() 获取 const char*从它。

如果 Add() 函数采用不同的类型,那仍然行不通,但是您没有提供足够的信息来了解您在询问什么。

关于c++ - 在 C++ 中将 std::string 转换为 Unicode 字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14978169/

相关文章:

c++ - QComboBox如何使用QItemSelectionModel?

PHP 检查一个字符串中的所有字符是否都是中文

XML UTF8 字符集范围

c# - 右单引号 (Unicode :(U+2019) Extended Ascii 146) causes SQL injection through MySqlParameter

string - 如何使用 grep 查找文件夹内的单词?

从 GETTEXT 获取的 C++ 变量作为 mysql_query 变量

c++ - 基类有不完整的类型

c++ - 在 OOP 中使用类 C API

c++ - 如何根据声明顺序对方法实现进行排序

基本函数的 C 编译错误