From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <6854804de7b1ceca96d3e2925d0f90ae@plan9.bell-labs.com> To: 9fans@cse.psu.edu Subject: Re: [9fans] wchar_t in ANSI C (was "Announce: port") From: "rob pike, esq." MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Date: Mon, 29 Apr 2002 08:53:45 -0400 Topicbox-Message-UUID: 803d39d6-eaca-11e9-9e20-41e7f4b1d025 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