« first day (932 days earlier)      last day (2924 days later) » 

00:23
Does C also support wide oriented binary stream?
There is no fread and fwrite for wide oriented binary stream
How could I write a struct to a file with wide char member in it?
fread takes the size of its members, so that should be sufficient.
00:45
@Unknown123 fwrite( &your_struct, sizeof(your_struct), 1 ) should do it. What's in the struct doesn't matter, just the size of it.
But if the struct contains pointers, that's a different matter.
But I have tried this code
http://ideone.com/ECuiA9

And I got an unwanted result
https://i.sstatic.net/2xHkV.png
01:04
Turn on warnings, you forgot to include wchar.h
You're probably inputting UTF-8 and that's not what wchar_t stores.
...rather that's not the encoding wprtinf expects.
Check your locale.
Also wprintf the struct before writing it to a file. I bet you get the same behavior.
@Unknown123 Your code works fine for me on OS X with the shell set to en_US.UTF-8 locale.
But I'm not terribly knowledgeable about character encoding in C.
01:38
How do I change the locale?
Even If I input ¤ 'CURRENCY SIGN' (U+00A4) '\164' It won't work either
wprintf(L"\n Input a sentence : "); fgetws(DATA.string, sizeof(DATA.string), stdin);

Even before fread and fwrite my DATA.string can't store it
01:55
@Schwern my sizeof(wchar_t) is 2, How about you?
02:36
4
You can't just shove UTF-8 into a wchar_t.
Like I said, I don't know much about encoding in C.
Endianness matters, too.
03:18
Well I don't know why,
Consider this code,

wchar_t i;
for(i = 0; i <= 1024; i++) putwchar(i);

I can only print up to 255 which is the range of unsigned char, what's wrong with this?
03:41
@Unknown123 That is weird. The vibe I'm getting from looking around is that wchar_t is not terribly useful. The size is implementation defined and can be as small as one byte.
Whereas UTF-8 can be 1 to 4 bytes.
@Unknown123 What you need is to ensure your C program inherits your environment's presumably UTF-8 locale. Do that with setlocale(LC_ALL, ""); from locale.h.
Then your code works.
@Unknown123 This might help. cprogramming.com/tutorial/unicode.html
03:57
I use Windows 10 with TDM-GCC 4.9.2
The result is more awkward if I called setlocale(LC_ALL, "");
What's wrong with this?
Maybe your locale is odd. What is your locale? (I don't know how to check this on Windows).
It's also possible you have a font that doesn't do Unicode very well.
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶ
That's what I get from...
#include <wchar.h>
#include <locale.h>

int main() {
char *locale;

locale = setlocale(LC_ALL, "");

wchar_t i;
for(i = 0; i < 1024; i++) {
putwchar(i);
}
}
But also note that UTF-8 is not contiguous.
It goes from 0xxxxxxx and then jumps to 110xxxxx10xxxxxx
My terminal appears to be interpreting the characters from 128 up as Latin1.
And so it yours... sort of.
Point is, anything between 128 (080) and 49279 (c079) is gibberish in UTF-8 and our terminals are doing their best to interpret it.

« first day (932 days earlier)      last day (2924 days later) »