9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "rob pike, esq." <rob@plan9.bell-labs.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] wchar_t in ANSI C (was "Announce: port")
Date: Mon, 29 Apr 2002 08:53:45 -0400	[thread overview]
Message-ID: <6854804de7b1ceca96d3e2925d0f90ae@plan9.bell-labs.com> (raw)

Here's a simple version of the problem.  Imagine you have a (bio) loop
along the lines of

	int c;

	while((c = Bgetc(&bWin)) != Beof){
		c = process(c);
		Bputc(&out, c);
	}

To make this work with UTF-8, all you do is change 'c' to 'rune'
in the calls:

	int c;

	while((c = Bgetrune(&bWin)) != Beof){
		c = process(c);
		Bputrune(&out, c);
	}

Loops like this are everywhere in the Plan 9 tools.  Bgetrune gets
called much more than Bgetc, I bet, at least for programs operating
on text.

No such charm works in ANSI C.

-rob



             reply	other threads:[~2002-04-29 12:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-29 12:53 rob pike, esq. [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-04-30 18:16 David Gordon Hogan
     [not found] <991a7d99caeee7b2557f759e7b5a8a77@caldo.demon.co.uk>
2002-04-30  9:40 ` Douglas A. Gwyn
     [not found] <9b8b28678237726753936b99587567ed@plan9.bell-labs.com>
2002-04-30  9:40 ` Douglas A. Gwyn
2002-04-29 12:42 rob pike, esq.
2002-04-29 16:18 ` Douglas A. Gwyn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6854804de7b1ceca96d3e2925d0f90ae@plan9.bell-labs.com \
    --to=rob@plan9.bell-labs.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).