From: Nick Owens <mischief@9.offblast.org>
To: 9front@9front.org
Subject: Re: [9front] mothra not respecting charset=utf-8
Date: Sun, 16 Feb 2014 06:46:18 -0800 [thread overview]
Message-ID: <20140216144618.GE25422@iota.offblast.org> (raw)
In-Reply-To: <1392549916.30058.83991793.135CF34A@webmail.messagingengine.com>
[-- Attachment #1: Type: text/plain, Size: 1402 bytes --]
On Sun, Feb 16, 2014 at 11:25:16AM +0000, Ethan Grammatikidis wrote:
> mischief reports (and i've confirmed) the following patch works. i'm
> almost scared to ask why.
>
> diff -r 709e18f21cad sys/src/cmd/mothra/rdhtml.c
> --- a/sys/src/cmd/mothra/rdhtml.c Sat Feb 15 17:18:58 2014 -0500
> +++ b/sys/src/cmd/mothra/rdhtml.c Sat Feb 15 03:13:05 2014 -0800
> @@ -166,7 +166,7 @@
> g->hbufp=g->hbuf;
> g->ehbuf=g->hbuf+n;
> }
> - c=*g->hbufp++&255;
> + c=*g->hbufp++;
> if(c=='\n') g->lineno++;
> return c;
> }
>
i'm not sure why i said that was a good idea.
maybe this one isn't either.
here we actually read full runes from the fd.
this seems to fix visiting
https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt
in mothra.
diff -r 709e18f21cad sys/src/cmd/mothra/rdhtml.c
--- a/sys/src/cmd/mothra/rdhtml.c Sat Feb 15 17:18:58 2014 -0500
+++ b/sys/src/cmd/mothra/rdhtml.c Sat Feb 15 04:10:34 2014 -0800
@@ -154,6 +154,7 @@
int n, c;
char err[1024];
if(g->hbufp==g->ehbuf){
+doread:
n=read(g->hfd, g->hbuf, NHBUF);
if(n<=0){
if(n<0){
@@ -166,7 +167,11 @@
g->hbufp=g->hbuf;
g->ehbuf=g->hbuf+n;
}
- c=*g->hbufp++&255;
+ if(!fullrune(g->hbufp, g->ehbuf - g->hbufp)) {
+ goto doread;
+ }
+
+ g->hbufp += chartorune((Rune*)&c, g->hbufp);
if(c=='\n') g->lineno++;
return c;
}
[-- Attachment #2: Type: application/pgp-signature, Size: 834 bytes --]
next prev parent reply other threads:[~2014-02-16 14:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-16 10:47 Ethan Grammatikidis
2014-02-16 11:25 ` [9front] " Ethan Grammatikidis
2014-02-16 14:46 ` Nick Owens [this message]
2014-02-16 18:38 ` cinap_lenrek
2014-02-18 22:32 ` Ethan Grammatikidis
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=20140216144618.GE25422@iota.offblast.org \
--to=mischief@9.offblast.org \
--cc=9front@9front.org \
/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).