Languages

Menu
Sites
Language
About a String

Hi,

I need your help, I would like convert a const Tizen::Base::String& from std::string&.

Do you know how I can do that?

Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

2 Replies
Serg Nik
Use this function:
std::string ToUtf8(const Osp::Base::String& badaStr)
{
	std::string utf8Str;
	if (badaStr.GetLength() == 0)
		return utf8Str;

	ByteBuffer* pBuffer = StringUtil::StringToUtf8N(badaStr);
	if (pBuffer != null)
	{
		int byteCount = pBuffer->GetLimit();
		char* chPtrBuf = new char[byteCount + 1];
		if (chPtrBuf != null) {
			pBuffer->GetArray((byte*) chPtrBuf, 0, byteCount);
			utf8Str.assign(chPtrBuf, byteCount);
			delete[] chPtrBuf;
		}
		if (pBuffer != null)
			delete pBuffer;
	}
	return utf8Str;
}
Benoit JOUANIGO
Thank you for your help