juce 编程问题

1.std::string juce:string转换

juce:string temp=parameter.c_str();

2.中文转换

(1) 1.在main 中添加

LookAndFeel::getDefaultLookAndFeel().setDefaultSansSerifTypefaceName(L"SimHei");

2.在需要显示中文的地方添加

String temp(L"中文11");
(2)

static std::wstring String2WString(const std::string& s)
	{
		std::string strLocale = setlocale(LC_ALL, "");
		const char* chSrc = s.c_str();
		size_t nDestSize = mbstowcs(NULL, chSrc, 0) + 1;
		wchar_t* wchDest = new wchar_t[nDestSize];
		wmemset(wchDest, 0, nDestSize);
		mbstowcs(wchDest, chSrc, nDestSize);
		std::wstring wstrResult = wchDest;
		delete[]wchDest;
		setlocale(LC_ALL, strLocale.c_str());
		return wstrResult;
	}
	juce::String name = (String2WString(m_nodeString)).c_str();

(3)

std::wstring_convert> conv(new std::codecvt("CHS"));
		//宽字符转为窄字符
		std::string str = conv.to_bytes(L"你好");
		//窄字符转为宽字符
		std::wstring wstr = conv.from_bytes(str);
			juce::String name = wstr .c_str();

你可能感兴趣的:(juce)