Unicode

Hi everybody!
I must read from unicode-file some text by ANSI C (NO C++). Yeah, I have found some algoritm from this site, but it doesn't work.
1
2
3
4
5
wchar_t string[10];
  FILE *f;
  f=fopen("test.txt", "rb");
  fgetws(string, 100, f);  
  printf("%s\n", string);


Where is a problem?
How is the file encoded? You need to be able to answer this question before proceeding.
symbol by symbol to hex-number for each symbol from table. And every symbols are just 1 byte in memory(ANSI). But in Unicode 1 symbol might be, for example, 2 bytes or more bytes, isn't it?
Every symbols are just numbers for pc.

Actually it works, but it works wrong, because I'm getting everytime just first letter from row and after that all what was in memory.


i think you mistyped string[100] with string[10].

does this work?

1
2
3
4
5
wchar_t string[100];
FILE *f;
f = fopen("test.txt", "rb");
fgetws(string, 100, f);
printf("%ls\n", string); // ls is for long string or meaning wide string 
Last edited on
No, it doesn't work. I've got a black screen and row: Press anykey to continue...
Topic archived. No new replies allowed.