typedef struct _monoString
{
void *player;
int id;
void *photonView;
char chars[1];
void PhotonViewInfo(void *player, int id, void *photonView);
const char* getString()
{
std::u16string u16string(reinterpret_cast<const char16_t *>(chars));
std::wstring wstring(u16string.begin(), u16string.end());
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> convert;
return convert.to_bytes(wstring).c_str();
}
std::string stdgetString()
{
std::u16string u16string(reinterpret_cast<const char16_t *>(chars));
std::wstring wstring(u16string.begin(), u16string.end());
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> convert;
return convert.to_bytes(wstring);
}
char* getRawChars()
{
return chars;
}
}
Can you show me how? I think I'm using stdgetStringThe simple fix is to get the std::string and do c_str on it
Sorry I'm a noob, can you show me in the code where I need to change it.instead of getString(), use getstdString().c_str
if (PhotonNetwork_get_player!=nullptr) {
auto playerlist = PhotonNetwork_get_otherPlayers();
for (int i = 0; i < playerlist->getLength(); ++i) {
auto players = playerlist->getPointer()[i];
if (players != NULL) {
env->SetObjectArrayElement(playerNames, i+1,
env->NewStringUTF(PlayerExtensions_GetNickname(players)->getString()));
}
}
}
return playerNames;
}
There, replace getString with getstdString().c_str()I'm not sure, I didn't make the code myself.
C++:if (PhotonNetwork_get_player!=nullptr) { auto playerlist = PhotonNetwork_get_otherPlayers(); for (int i = 0; i < playerlist->getLength(); ++i) { auto players = playerlist->getPointer()[i]; if (players != NULL) { env->SetObjectArrayElement(playerNames, i+1, env->NewStringUTF(PlayerExtensions_GetNickname(players)->getString())); } } } return playerNames; }
Lol cheersThere, replace getString with getstdString().c_str()
Edit* alright, didn't see your post before posting this
We use cookies to personalize content and ads, to provide social media features and to analyse our traffic. We also share necessary information with our advertising and analytics partners to optimize your experience on our site.
Learn more about cookies
We use cookies to personalize content and ads, to provide social media features and to analyse our traffic. We also share necessary information with our advertising and analytics partners to optimize your experience on our site.
Learn more about cookies