Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #5945

Re: fgetwc doesn't read Unicode

From Nobody <nobody@nowhere.com>
Subject Re: fgetwc doesn't read Unicode
Date 2011-06-13 02:09 +0100
Message-Id <pan.2011.06.13.01.08.53.985000@nowhere.com>
Newsgroups comp.lang.c
References <isnn5i$cuu$1@news.onet.pl> <pan.2011.06.09.01.39.26.485000@nowhere.com> <it20vb$n3i$1@news.onet.pl>
Organization Zen Internet

Show all headers | View raw


On Sun, 12 Jun 2011 11:30:19 +0200, felix.leg wrote:

>> fgetwc() assumes that the file is in the locale's encoding. If the file
>> is in e.g. UTF-8, then you need to use a UTF-8 locale. This means
>> calling setlocale(LC_CTYPE, ...); if you use "" as the locale, then the
>> appropriate environment variables need to indicate a UTF-8 locale.
> [..cut..]
>> At startup, all locale categories default to "C" (which has ASCII as its
>> encoding). You have to call setlocale() to change it.
> 
> So dealing with Unicode in C is inextricably linked with Locale?

Dealing with "characters" in C is inextricably linked with the locale. You
can avoid using the locale for encoding by using e.g. iconv to convert
between wchar_t[] and char[] then reading/writing char[] with the standard
library. But there are still issues such as collating order, numeric
formatting, etc which are locale-dependent even with wchar_t[].

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

fgetwc doesn't read Unicode "felix.leg" <felix.leg@vp.pl> - 2011-06-08 13:41 +0200
  Re: fgetwc doesn't read Unicode jt@toerring.de (Jens Thoms Toerring) - 2011-06-08 20:18 +0000
  Re: fgetwc doesn't read Unicode Nobody <nobody@nowhere.com> - 2011-06-09 02:39 +0100
    Re: fgetwc doesn't read Unicode "felix.leg" <felix.leg@vp.pl> - 2011-06-12 11:30 +0200
      Re: fgetwc doesn't read Unicode Nobody <nobody@nowhere.com> - 2011-06-13 02:09 +0100
      Re: fgetwc doesn't read Unicode jt@toerring.de (Jens Thoms Toerring) - 2011-06-13 21:38 +0000
  Re: fgetwc doesn't read Unicode Dirk Krause <devnull@fh-schmalkalden.de> - 2011-06-09 13:19 +0000

csiph-web