Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8208227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:16:09+00:00 2026-06-07T09:16:09+00:00

characters.txt has the content (output from od -c): 0000000 % ( ) * +

  • 0

characters.txt has the content (output from od -c):

0000000   %   (   )   *   +   ,   -   .   /   0   1   2   3   4   5   6
0000020   7   8   9   <   =   >   ?   [   ]  \n   A   B   C   D   E   F
0000040   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V
0000060   W   X   Y   Z  \n   a   b   c   d   e   f   g   h   i   j   k
0000100   l   m   n   o   p   q   r   s   t   u   v   w   x   y   z  \n
0000120 316 223 316 224 316 230 316 233 316 236 316 243 316 246 316 250
0000140 316 251 316 261 316 262 316 263 316 264 316 265 316 266 316 267
0000160 316 270 316 271 316 272 316 273 316 274 316 275 316 276 316 277
0000200 317 200 317 201 317 202 317 203 317 204 317 205 317 206 317 207
0000220 317 210 317 211  \n

That is, some ASCII followed by some Greek in UTF-8. I want to read these characters with (the following which is written after examples given in the glibc info pages)

wint_t* read_characters() {
    char *filename = "characters.txt";
    FILE *infile;
    infile = fopen (filename, "rb");
    printf ("File orientation: %d\n", fwide (infile,0));
    static wint_t b[16384], c, *p;
    p = b;
    while ((p-b)<sizeof(b)-4 && (c = fgetwc (infile)) != WEOF)
        *p++ = c;
    *p++ = WEOF;
    printf("\nRead %ld wint_t chars from characters.txt\n", p-b);
    return b;
}

The output is:

File orientation: 0
Read 81 wint_t chars from characters.txt

This means reading stopped with the first Greek character. Why? I’m using no signed variable that could fake a WEOF. Who can help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:16:10+00:00Added an answer on June 7, 2026 at 9:16 am

    The solution (hinted at by n.m.) was to include this call

    setlocale(LC_ALL, "en_US.UTF-8");
    

    and this is necessary even if LC_ALL is set globally, because C programs always start out in the “C” locale. If you want to use something else you always have to set it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to read data about MMORPG characters from a .txt file and then
I've a .txt file which has control characters associated with email address.Some thing line
I am calling a .txt file from a jquery ajax call. It has some
I have file called denem.txt and has content 123456789 123456789 123456789 When we open
I insert from csv characters from different languages.. I apply this to every set
The use of FileReference has a constraint on valid characters. Error: Error #2087: The
I have names of all files in output.txt but I do not have folderpath
My file(sample.txt) has 10 chars. I opened the file in write mode, have done
I read a file that has utf8 characters like this: FILE *FileIN,*FileOUT; FileIN=fopen(filename,r); char
Suppose I have two text files. The first one, called reference.txt has the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.