+ 1

How is it possible to attach strings to an array.

13th Feb 2017, 1:18 PM
jake taylor
jake taylor - avatar
3 Réponses
+ 3
std::string is just a class that wraps a character array "under the hood". At its most basic level a string is just an array of characters like this: char s[] = "Hello world"; Here the string is made up of an array of ASCII characters (which is coded on 1 byte). But you can also have: wchar_t s[] = "Hello world"; //"Wide" character array "Wide" characters is where it gets a bit more complicated (it is system dependent) since now we are now in the domain of Unicode strings - these come in a number of encodings: UTF32 (which is 4 bytes), UTF16 (which is 2 bytes), and UTF8 (which has variable size between 1 and 3 bytes). Unicode uses any of the above encodings to map "code units" to a "code point" (the actual character). But sometimes even that is not enough, so Unicode defines "graphemes" which is where a number of code points makes up some composite character. Note that in the Windows x32 bit world Unicode was not that well supported and on earlier MS C++ compilers wchar_t was defined as UCS2 encoding, which was similar to UTF16 (but not an exact match).
13th Feb 2017, 3:00 PM
Ettienne Gilbert
Ettienne Gilbert - avatar
0
( ͡° ͜ʖ ͡°)
13th Feb 2017, 1:57 PM
SIMOMEGA
SIMOMEGA - avatar