How can i convert a wchar_t ?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Jorik
Posts: 44
Joined: Tue Dec 08, 2009 4:47 pm

How can i convert a wchar_t ?

Post by Jorik »

Hi,

i using a IGUIEditBox and save the text written in there in a wchar_t variable.

but to send the name to a server i need a string variable.

I found no way to convert a wchar_t to a string.

is there any possiblillity?
CuteAlien
Admin
Posts: 10021
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

There are many ways to represent strings (null-terminated c-strings with char*, with wchar_t*, irrlicht strings, stl strings, ...), so if you say "string" variable we don't really know what you mean. You have to know the type. But anyway, please always use the forum search before asking - this is a topic for which you will find a huge number of threads.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Jorik
Posts: 44
Joined: Tue Dec 08, 2009 4:47 pm

Post by Jorik »

I used the search function, but found no function i can use.

I want to convert a wchar_t into a std::string
Murloc992
Posts: 272
Joined: Mon Apr 13, 2009 2:45 pm
Location: Utena,Lithuania

Post by Murloc992 »

Code: Select all

irr::core::stringw make_wide (const irr::core::string& s) 
{ 
  return irr::core::stringw (s); 
} 

irr::core::stringc make_narrow (const irr::core::stringw& w) 
{ 
  return irr::core::stringc (w); 
} 

std::stringw make_std (const irr::core::stringw& w) 
{ 
  return std::wstring (w.c_str(), w.size()); 
} 

std::string make_std (const irr::core::stringc& s) 
{ 
  return std::string (s.c_str(), s.size()); 
} 

irr::core::stringc make_irr (const std::string& s) 
{ 
  return irr::core::stringc (s.c_str(), s.size()); 
} 

irr::core::stringw make_irr (const std::wstring& w) 
{ 
  return irr::core::stringw (w.c_str(), w.size()); 
}
Jorik
Posts: 44
Joined: Tue Dec 08, 2009 4:47 pm

Post by Jorik »

Thank you very much :D
Post Reply