question archive I need help for my cs50 test question about python on counting characters in a UTF-8 unicode file They have provided the code for counting the characters in a ASCII file, and they ask us to make modifications so it can count characters in a UTF-8 unicode File Here is the code, I need help in modifying in to count the characters of UTF-8 file #include <stdbool
Subject:Computer SciencePrice: Bought3
I need help for my cs50 test question about python on counting characters in a UTF-8 unicode file
They have provided the code for counting the characters in a ASCII file, and they ask us to make modifications
so it can count characters in a UTF-8 unicode File
Here is the code, I need help in modifying in to count the characters of UTF-8 file
#include <stdbool.h>
#include <stdio.h>
typedef unsigned char BYTE;
int main(int argc, char *argv[])
{
if (argc != 2)
{
printf("Usage: ./count INPUTn");
return 1;
}
FILE *file = fopen(argv[1], "r");
if (!file)
{
printf("Could not open file.n");
return 1;
}
int count = 0;
while (true)
{
BYTE b;
fread(&b, 1, 1, file);
if (feof(file))
{
break;
}
count++;
}
printf("Number of characters: %in", count);
}
It would greatly appreciated if you can help me with this.
Thank you,
Sumantra