472,954 Members | 2,067 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 software developers and data experts.

converting std::string to std::wstring

I have a an app that I'm writing which uses char and std::string. I'm using
a library which expects wchar_t arrays.

Is there a standard way to convert between std::string and std::wstring, or do
I need to use something like std::transform()?

Thanks

Jul 19 '05 #1
1 12183

"red floyd" <no*****@here.dude> wrote in message news:I3***************@newssvr29.news.prodigy.com. ..
I have a an app that I'm writing which uses char and std::string. I'm using
a library which expects wchar_t arrays.

Is there a standard way to convert between std::string and std::wstring, or do
I need to use something like std::transform()?

Well, there's no real PORTABLE way... it might not even be possible. The whole
concept of the mapping between mb to wc characters is highly implemetnation
dependent. C++ is rather schizoid about whether it's multibyte or wide character
based having a complete implementation of neither.

The best bet is the codecvt C++ class or the mbtowc family of functions in the
C library. All of these work on arrays of characters and not strings, you could
use transform to warp calls to these, but there's no canned function that
does what you want I suspect.

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Flzw | last post by:
How to convert a std::string to a WCHAR* ? is there any methods or something ? I can't find. Thanks
3
by: Lars Nielsen | last post by:
Hey there I have a win32 application written i c++. I have a std::vector of std::string's i will fill with filenames. typedef vector<std::string> strvector; strvector vFiles; ...
9
by: vsgdp | last post by:
Hi, Is there a unicode equivalent to std::string?
5
by: Karthik | last post by:
Hello, How can I convert a BSTR data type to std::string??? Thanks a much! Karthik
37
by: jortizclaver | last post by:
Hi, I'm about to develop a new framework for my corporative applications and my first decision point is what kind of strings to use: std::string or classical C char*. Performance in my system...
14
by: rohitpatel9999 | last post by:
Hi While developing any software, developer need to think about it's possible enhancement for international usage and considering UNICODE. I have read many nice articles/items in advanced C++...
10
by: Jeffrey Walton | last post by:
Hi All, I've done a little homework (I've read responses to similar from P.J. Plauger and Dietmar Kuehl), and wanted to verify with the Group. Below is what I am performing (Stroustrup's...
3
by: Angus | last post by:
I can see how to get a char* but is it possible to get a wide char - eg wchar_t?
10
bajajv
by: bajajv | last post by:
Hi, I was trying to implement CString with std::string and std::wstring. class CString { public: std::string str; CString() {str = "ABCD";} //this works }: class CString {
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.