473,799 Members | 2,868 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to convert char* to WCHAR* in C

Dear all,

Kindy help to convert the char* ( LPCSTR) to WCHAR*(LPCWSTR) . Would be
great if you tell if any function does this job in VC++.

Quick response will be greatfull...as its blocked...

Thanks,
Sweety

Feb 22 '06 #1
4 44378
Hi Sweety,

You can try MultiByteToWide Char.

The MultiByteToWide Char function maps a character string to a
wide-character (Unicode) string. The character string mapped by this
function is not necessarily from a multibyte character set.

int MultiByteToWide Char(
UINT CodePage, // code page
DWORD dwFlags, // character-type options
LPCSTR lpMultiByteStr, // string to map
int cbMultiByte, // number of bytes in string
LPWSTR lpWideCharStr, // wide-character buffer
int cchWideChar // size of buffer
);

For more information, please refer to:
http://msdn.microsoft.com/library/de...icode_17si.asp

Hope this helps.
Regards.
Harry

Feb 22 '06 #2

sweety wrote:
Dear all,

Kindy help to convert the char* ( LPCSTR) to WCHAR*(LPCWSTR) . Would be
great if you tell if any function does this job in VC++.


Try looking up the standard function "mbtowc".

That MAY do what you want. It depends on what is in the char*. If it
ASCII or
UTF-8, that is fine. If not (e.g. it is the common iso-8859-1 8 bit
encoding
(rather like the old Windows "code page" 1252), you need to convert it
to utf-8 first.
I think there is no standard way to do that, but there are lots of
libraries
around (<OT>example: expat is pretty portable I think</OT>).

-David

Feb 22 '06 #3
On 22 Feb 2006 00:25:38 -0800, in comp.lang.c , "sweety"
<ur********@gma il.com> wrote:
Dear all,

Kindy help to convert the char* ( LPCSTR) to WCHAR*(LPCWSTR) . Would be
great if you tell if any function does this job in VC++.


This isn't a C question, since both the types you refer to are part of
Microsoft's language extensions. I'd suggest you search the MSDN
online for wide char to char conversions
Mark McIntyre
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Feb 22 '06 #4
On 2006-02-22, David Resnick <ln********@gma il.com> wrote:

sweety wrote:
Dear all,

Kindy help to convert the char* ( LPCSTR) to WCHAR*(LPCWSTR) . Would be
great if you tell if any function does this job in VC++.
Try looking up the standard function "mbtowc".

That MAY do what you want. It depends on what is in the char*. If it
ASCII or UTF-8, that is fine. If not (e.g. it is the common
iso-8859-1 8 bit encoding (rather like the old Windows "code page"
1252), you need to convert it to utf-8 first.


That is not at all clear. There is no requirement that the "multibyte"
representation actually contains any multibyte characters, and even if
so, a system could well use something like Shift-JIS or ISO-2022 for the
multibyte encoding.

(Forgetting for the moment the fact that the system is not required to
use ASCII for the representation of the basic execution character set,
though the characters in this set are, of course, required to be
represented by single bytes)
I think there is no standard way to do that, but there are lots of
libraries around (<OT>example: expat is pretty portable I think</OT>).

-David

Feb 22 '06 #5

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

Similar topics

5
22070
by: Brad Moore | last post by:
Hey all, I'm getting the following compiler error from my code. I was wondering if anyone could help me understand the concept behind it (I actually did try and compile this degenerate example). int foo(const char* argv) { return 0; } int main(int argc, char* argv) {
7
66768
by: MilanB | last post by:
Hello How to convert char to int? Thanks
2
8184
by: Alper Akcayoz | last post by:
Hello Esteemed Developpers I would like to thank you in advance for your sincere responses I am a fresh Visual C++ .NET Developer. Can you kindly guide me for How to Convert char* to System::String
1
19202
by: Elioth | last post by:
Hi... I need to know how to convert Char Array to Byte Array and vice-versa in VB 2K5 Thanks for all help. Elioth
2
94061
by: Joah Senegal | last post by:
Hello I need to convert a chat to a string... but I don't know how to do this. i;ve searched the internet but I've only find some code to convert char * to string or char to string.... but I just need char to string. Anyone knows how to do this ? thanks!!!!
3
5359
by: simon | last post by:
I am a fresh Visual C++ .NET Developer. Can you kindly guide me for How to Convert char to System::String I am using windows forms and trying to set a text value referencing the method className() of an object of class HetConvert (my own) this returns a char - which as you can see from the code below I am trying to pass to label1->Text - but this expects a String^ any clues anyone
2
4163
by: Rasheed | last post by:
Hi, i have a char pointer buffer which will hold the bitmap buffer, So i need to convert char *buffer as a bitmap. becuase when i draw on the Dialog using char *buffer. Nothing will be dispalyed. So kindly can any body help me how to convert char *buffer to bitmap. i want the solution in C++
1
2779
by: helios | last post by:
Hi all, I'm resolved problem. and I want anybody need me that convert char to array bits char ConvertChar2ArrayBit(char ch) { char Bits; .... return Bits; } for example: A after converted: 10000010
3
19874
by: mamul | last post by:
Hi please some one can help me. how to convert char * to string? i have take char *argv from command line and want to pass to a function as string object(string str) i want to first convert argv to string object of type str, then pass to function(). please help me how to convert this
3
6754
by: DaveRook | last post by:
Hi I've had a few error messages with this I don't understand why. It works fine in a Windows Form, but now moving it to a website, it's not working. I don't have the option to count the lines as I did with Windows Forms so I assume the best way is to use the split method. However, the split method only returns Character Arrays, and I want a string, so am calling the split from the Text.RegularExpression namespace. I am trying to split...
0
9546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10491
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10268
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10247
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10031
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.