473,804 Members | 3,021 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

char to wchar_t conversion

wchar_t c1 = wchar_t('A');
wchar_t c2 = L'A';

Is c1 equal to c2?

If they are not equal, how can I create wchar_t character representing the
same character as some char value?

cheers,
Marcin
Dec 7 '05 #1
1 6899
Marcin Kalicinski <ka****@poczta. onet.pl> wrote:
| wchar_t c1 = wchar_t('A');
| wchar_t c2 = L'A';
|
| Is c1 equal to c2?

I could not find any guarantee for that in the C++ standard. The only
guarantee i found is that both char(0) and wchar_t(0) shall both have
only zero bits. Apart from that the standard only has limited demands
on the character sets represented by char and wchar_t. Amongst others,
both shall contain the letter A, and rest of the English characters.

| If they are not equal, how can I create wchar_t character representing the
| same character as some char value?

Create a conversion function for the target system. It will probably
port easily if you need it to. Your compiler's documentation should
contain information on how you can write the function.

Since you are asking, you are probably interested in the iconv function,
which is present on UNIX systems. See <URL: http://www.gnu.org/software/libiconv/>,
or search the web.
--
Robert Bauck Hamar
Dec 7 '05 #2

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

Similar topics

2
1123
by: Peteroid | last post by:
The following code: char x_char = '0' ; String^ x_str = c_char.ToString( ) ; results in: x_str = = "48" and not:
23
8209
by: Steven T. Hatton | last post by:
This is one of the first obstacles I encountered when getting started with C++. I found that everybody had their own idea of what a string is. There was std::string, QString, xercesc::XMLString, etc. There are also char, wchar_t, QChar, XMLCh, etc., for character representation. Coming from Java where a String is a String is a String, that was quite a shock. Well, I'm back to looking at this, and it still isn't pretty. I've found...
2
5044
by: Alejandro Aleman | last post by:
Hello! i know this may be a newbie question, but i need to convert a string from System::String^ to char*, in the msdn page tells how, but i need to set to /clr:oldSyntax and i dont want it because in further editions of .net this will be deprecated or so on.. . so, please, anybody can tellme how to convert from System::String::^ to char* and viceversa?
4
22053
by: uday.sen | last post by:
Hi, I need to convert a string from UTF8 to wide character (wchar_t *). I perform the same in windows using: MultiByteToWideChar(CP_UTF8, 0, pInput, -1, pOutput, nLen); However, in linux this API is not available. However, there exists mbstowcs() API, which converts multibyte string to wide character. But will this API convert UTF8 encoded string to wide character? Or this
1
2441
by: Suman | last post by:
Hello All, Given a structure: struct s { char *name; wchar_t *surname; }; I wish to define a friend function for the above struct: std::ostream& operator<<(std::ostream& out, const s& x);
0
1503
by: Khadar123 | last post by:
CString str,s; str = _T("DATA"); / str = "DATA"; const wchar_t *c = sPorts.GetBuffer(0); s.Format(_T("%s"),c); AfxMessageBox(s); or Printf/cout.....
1
1899
by: George2 | last post by:
Hello everyone, Here is the code, and if I change line from static wchar_t* p = {PREFIX((wchar_t*)_TEXT("FOO"))}; to static wchar_t* p = {PREFIX(_TEXT("FOO"))};
1
3560
by: dynature | last post by:
Hi, Any help, how to convert float to unicode string? gcvt() wont work on visual c++ 2005. Thnks in advance - nestor
5
4750
by: Samant.Trupti | last post by:
Hi, There is one thing I am cofused about.... If I have a declareation say char str; Now if I want to change it to wchar so do I have to change it like .... wchar_t str; or double the size? like
0
9584
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
10583
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
10337
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...
0
10082
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...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
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
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
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.