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


Groups > comp.lang.c > #97804

Re: UTF-8 with C, simply

From Nobody <nobody@nowhere.invalid>
Newsgroups comp.lang.c
Subject Re: UTF-8 with C, simply
Date 2016-12-01 01:52 +0000
Organization A noiseless patient Spider
Message-ID <pan.2016.12.01.01.54.48.31000@nowhere.invalid> (permalink)
References <6a3e7ab3-eb0d-4794-befb-adae3729c746@googlegroups.com>

Show all headers | View raw


On Sun, 27 Nov 2016 18:09:53 -0800, luser droog wrote:

> call setlocale(LC_CTYPE, "UTF-8");
> then use fgetwc() and fputwc() to read and write ucs2 or ucs4 depending on
> the implementation's definition of wchar_t, right? And it's all automagic?

"UTF-8" probably isn't a valid locale.

On Linux, you'd typically use something like "en_US.UTF-8" to select the
en_US locale with utf-8 as the character encoding. wchar_t will always be
Unicode (UCS-4).

On Windows, your life will be somewhat harder. Windows barely tolerates
the ISO C APIs, and doesn't use UTF-8 for any of its locales. If you want
Unicode, you're supposed to use UTF-16 and wchar_t* for everything, which
means using non-standard functions such as

FILE *_wfopen(const wchar_t *filename, const wchar_t *mode);

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


Thread

UTF-8 with C, simply luser droog <luser.droog@gmail.com> - 2016-11-27 18:09 -0800
  Re: UTF-8 with C, simply James Kuyper <jameskuyper@verizon.net> - 2016-11-27 22:05 -0500
  Re: UTF-8 with C, simply Lorinczy Zsigmond <zsiga@nospam.for.me> - 2016-11-28 09:42 +0100
    Re: UTF-8 with C, simply James Kuyper <jameskuyper@verizon.net> - 2016-11-28 09:10 -0500
      Re: UTF-8 with C, simply Philipp Klaus Krause <pkk@spth.de> - 2016-11-28 21:55 +0100
        Re: UTF-8 with C, simply "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-28 16:18 -0500
  Re: UTF-8 with C, simply Siri Cruise <chine.bleu@yahoo.com> - 2016-11-28 07:00 -0800
    Re: UTF-8 with C, simply Philipp Klaus Krause <pkk@spth.de> - 2016-11-28 21:53 +0100
    Re: UTF-8 with C, simply Keith Thompson <kst-u@mib.org> - 2016-11-28 21:38 -0800
  Re: UTF-8 with C, simply Nobody <nobody@nowhere.invalid> - 2016-12-01 01:52 +0000
    Re: UTF-8 with C, simply luser droog <luser.droog@gmail.com> - 2016-11-30 18:20 -0800
      Re: UTF-8 with C, simply luser droog <luser.droog@gmail.com> - 2016-11-30 18:25 -0800
        Re: UTF-8 with C, simply luser droog <luser.droog@gmail.com> - 2016-11-30 18:28 -0800

csiph-web