Characters in D
Rumbu
rumbu at rumbu.ro
Sat Nov 2 19:18:12 UTC 2019
Your привет memory representation will look different depending
on the encoding formats:
//utf-8, you cannot put 'п' in a single char, so it will be
encoded as 2 bytes: 0xd0 0xbf
char[] cyrillics = [0xd0, 0xbf, 0xd1, 0x80, 0xd0, 0xb8, 0xd0,
0xb2, 0xd0, 0xb5, 0xd1, 0x82]
//utf-16, a wchar has enough space to accommodate any letter from
привет
wchar[] cyrillics = [0x043f, 0x0440, 0x0438, 0x0432, 0x0435,
0x0442]
//or - this is the same because each letter will fit in a wchar:
wchar[] cyrillics = ['п', 'р', 'и', 'в', 'е', 'т']
//utf-32, a dchar has enough space to accommodate any letter from
привет
dchar[] cyrillics = [0x0000043f, 0x00000440, 0x00000438,
0x00000432, 0x00000435, 0x00000442]
//or - this is the same because each letter will fit in a dchar:
dchar[] cyrillics = ['п', 'р', 'и', 'в', 'е', 'т']
More information about the Digitalmars-d
mailing list