473,809 Members | 2,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

wchar_t and wide characters

jjf
Do Standard C's wide characters and wide strings require absolutely
that each character be stored in a single wchar_t, or can characters be
"multi-wchar_t" in the same way that they can be multibyte? Is it a
requirement that the number of wchar_t's in a string is the same as the
number of characters in the string (give or take the terminal null
character)?

The particular case I'm puzzling over is whether or not it is
conforming for an implementation with a 16-bit wchar_t to use UTF-16 as
a character encoding, since this would require some characters to be
endoded as two wchar_t's. I understand that this is what one popular
C-like implementation does.

Mar 13 '06 #1
1 2328
<jj*@bcs.org.uk > wrote in message
news:11******** ************@u7 2g2000cwu.googl egroups.com...
Do Standard C's wide characters and wide strings require absolutely
that each character be stored in a single wchar_t, or can characters be
"multi-wchar_t" in the same way that they can be multibyte? Is it a
requirement that the number of wchar_t's in a string is the same as the
number of characters in the string (give or take the terminal null
character)?

The particular case I'm puzzling over is whether or not it is
conforming for an implementation with a 16-bit wchar_t to use UTF-16 as
a character encoding, since this would require some characters to be
endoded as two wchar_t's. I understand that this is what one popular
C-like implementation does.


The *intent* is that an array of wchar_t use one element to store
each character. Certainly all the added wide-character functions
implicitly assume so. There's nothing stopping an implementation
from using UTF-16 as a wide-character encoding, however, and not
living up to this intent. Indeed, as you observe, UTF-16 is now
used in implementations that thought UCS-2 would be sufficient a
decade ago. Some of us have bowed to the inevitable and now supply
the necessary conversion software to support what you call
multi-wchar_t encodings.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Mar 13 '06 #2

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

Similar topics

22
3539
by: Albert Oppenheimer | last post by:
I thought my program had to be caught in a loop, and cancelled it through the task manager. It took about one second in Java, but re-implemented in C, it had already run over one minute. I set up a debugger to display the current location each loop and let it run. It did reach completion, but it took 20 minutes. I replaced the calls to wcschr in my program with calls to this substitute: static WCHAR* altchr(register WCHAR* s,...
7
31010
by: abbu | last post by:
int main() { wchar_t p="Good Morning"; } How to use cout on p. That is, can I use cout<<p; It's not working.
4
22060
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
4
12462
by: sarathy | last post by:
Hi , Can anyone please explain what are wide characters (wchar_t). Why is it used when there is char datatype ? Regards, Sarathy
1
6050
by: Marcel Ruff | last post by:
Hi, i have the question on how to determine the string length of a wide string and a multibyte string: 1. Number of letters (one letter may use three bytes) 2. Number of bytes In the code snippet *p points to one chinese word which i copy/pasted from my browser from some chinese homepage,
8
23912
by: Rui Maciel | last post by:
I've just started learning how to use the wchar_t data type as the basis for Unicode strings and unfortunately I'm having quite a bit of problems, both in the C front and the Unicode front. In this case,it seems that the wprintf function isn't able to print a string beyond the first character. I don't have a clue why this is happening. Here is the test code: <code> #include <stdlib.h>
4
9804
by: interec | last post by:
Hi Folks, I am writing a c++ program on redhat linux using main(int argc, wchar_t *argv). $LANG on console is set to "en_US.UTF-8". g++ compiler version is 3.4.6. Q1. what is the encoding of data that I get in argv ? Q2. what is encoding of string constants defined in programs (for example L"--count") ?
1
6277
by: Rui Maciel | last post by:
I'm trying to use the getwc() function to get individual characters from a stream but I've stumbled on a type conversion problem. The getwc() function returns a type wint_t instead of a wchar_t and there isn't any information on how to convert a wint_t type to wchar_t and vice-versa. As the purpose of the wint_t type in that particular case is to serve as a data type capable of storing all the possible values held by wchar_t along with...
16
4372
by: Michael Brennan | last post by:
I guess this question only applies to programming applications for UNIX, Windows and similiar. If one develops something for an embedded system I can understand that wchar_t would be unnecessary. I wonder if there is any point in using char over wchar_t? I don't see much code using wchar_t when reading other people's code (but then I haven't really looked much) or when following this newsgroup. To me it sounds reasonable to make sure...
0
10378
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
10391
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
10121
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
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
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
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4333
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
3862
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
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.