cwchar-twidecharwchar

Effect of Wide Characters/ Strings on a C Program


Below is an excerpt from an old edition of the book Programming Windows by Charles Petzold

There are, of course, certain disadvantages to using Unicode. First and foremost is that every string in your program will occupy twice as much space. In addition, you'll observe that the functions in the wide-character run-time library are larger than the usual functions.

Why would every string in my program occupy twice the bytes, should not only the character arrays we've declared as storing wchar_t type do so?

Is there perhaps some condition that if a program is to be able to work with Long values, then the entire program mode it'll operate on is altered?

Usually if we declare a long int, we never fuss over or mention the fact that all ints will be occupying double the memory now. Are strings somehow a special case?


Solution

  • Why would every string in my program occupy twice the bytes, should not only the character arrays we've declared as storing wchar_t type do so?

    As I understand it, it is meant, that if you have a program that uses char *, and now you rewrite that program to use wchar_t *, then it will use (more than) twice the bytes.