簡體   English   中英

在c ++中將std :: string轉換為Unicode String

[英]Converting std::string to Unicode String in c++

我有個問題。 我需要將字符串類型轉換為unicode。 我知道metod喜歡

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()函數采用不同的類型,但仍未提供足夠的信息來了解您所詢問的內容,那么仍然無效。

使用字符串流

#include <sstream>
std::stringstream ss;
ss << "some text" << mystring << "some text";
Form1->Memo1->Lines->Add(ss.str().c_str());

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM