0

I'm trying to read in a wide file,and I have this wide string example, but I'm not sure what makes it wide. Is it each 0x42, or is it because there's a lot of them? I need to figure this out so I can make what's in my file wide.

This is my wide string. What makes it wide, other than the w in wchar_t:

wchar_t nm[] = {0x42, 0x65, 0x6E, 0x6A, 0x61, 0x6D, 0xED, 0x6E, 0x20, 0x70, 0x69, 0x64, 0x69, 0xF3, 0x20, 0x75, 0x6E, 0x61, 0x20, 0x62, 0x65, 0x62, 0x69, 0x64, 0x61, 0x20, 0x64, 0x65, 0x20, 0x6B, 0x69, 0x77, 0x69, 0x20, 0x79, 0x20, 0x66, 0x72, 0x65, 0x73, 0x61, 0x3B, 0x20, 0x4E, 0x6F, 0xE9, 0x2C, 0x20, 0x73, 0x69, 0x6E, 0x20, 0x76, 0x65, 0x72, 0x67, 0xFC, 0x65, 0x6E, 0x7A, 0x61, 0x2C, 0x20, 0x6C, 0x61, 0x20, 0x6D, 0xE1, 0x73, 0x20, 0x65, 0x78, 0x71, 0x75, 0x69, 0x73, 0x69, 0x74, 0x61, 0x20, 0x63, 0x68, 0x61, 0x6D, 0x70, 0x61, 0xF1, 0x61, 0x20, 0x64, 0x65, 0x6C, 0x20, 0x6D, 0x65, 0x6E, 0xFA, 0x2E, 0x00};

I was told that a real wide string will fill extra bits in the string.

I was reading wide vs standard but I'm still not sure what is making this one wide.

Community
  • 1
  • 1
Michele
  • 3,617
  • 12
  • 47
  • 81
  • 1
    Your question is rather unclear. `wchar_t` is the *wide* character type. What do you mean with "read in a wide file?" Wide vs. narrow is a property of C++ character types, not of file contents. – Angew is no longer proud of SO Apr 08 '17 at 19:05
  • The `w` in `wchar_t` stands for "wide", but I'm not sure what your question is beyond that. – Quentin Apr 08 '17 at 19:05
  • see my extra comments above. I'm not sure why this particular string fits the extra bit filling criteria for wide strings. – Michele Apr 08 '17 at 19:08
  • There is no such thing as a "wide" file. A test file can be encoded in ANSI, UTF-8, UTF-16, UTF-32, and a whole bunch of other encodings invented by people trying to be smart. The whole "wide vs ansi" thing is something invented in the era of Windows 95 that for some reason stuck until today. Read up on encodings and what the C++ types are (and what they are not) and stop confusing yourself. – rubenvb Apr 08 '17 at 21:00
  • If there are Japanese characters, it needs to be utf16, like ":\"\\u9CE5\"},\n" – Michele Apr 09 '17 at 19:30

1 Answers1

-1

This data is 'wide' because some of the values (all of those over 0x7F) are outside of the range of those for char (-128 to 127) and thus they are promoted to ints by the compiler, which cannot fit in a char. wchar_t is the wide char type, which has more bits in it than char, and thus can store values outside of that range. The actual number of bits in wchar_t varies depending on the platform.

JeremiahB
  • 896
  • 8
  • 15
  • so are you saying that the string doesn't fit the bill for wide then? If I was on widows, what number would be considered wide? – Michele Apr 08 '17 at 19:12
  • 1
    `char` is not necessarily -128 to 127, nor even necessarily signed. Anyway, all of those constants are `int` from the get-go. – chris Apr 08 '17 at 19:16
  • I am saying that it does fit the bill. I will edit my answer for clarity. – JeremiahB Apr 08 '17 at 19:18