From: Matthew Wilcox <willy@debian.org>
To: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Matt Domsch <Matt_Domsch@dell.com>,
linux-ia64@vger.kernel.org,
Matt Tolentino <matthew.e.tolentino@intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] add some EFI device smarts
Date: Wed, 21 Apr 2004 14:22:28 +0000 [thread overview]
Message-ID: <20040421142228.GM18329@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <200404210659.22884.bjorn.helgaas@hp.com>
On Wed, Apr 21, 2004 at 06:59:22AM -0600, Bjorn Helgaas wrote:
> > > + /* Convert Unicode to normal chars */
> > > + for (i = 0; i < (name_size/sizeof(name_unicode[0])); i++)
> > > + name_utf8[i] = name_unicode[i] & 0xff;
> > > + name_utf8[i] = 0;
> >
> > I've never had a clear understanding of this. It's not really UTF8
> > (else straight ASCII text could be used), but more like UCS2.
>
> I don't understand Unicode either. Maybe the attached is a little
> closer? The EFI spec (1.10, table 2-2) says strings are stored in
> UTF-16, and I think that UTF-16 is the same as ASCII for
> (0 < c <= 0x7f).
Ah, I know this one ...
UTF-16 is like UCS-2 except that it has escapes to let you use past the
first plane of Unicode. That is, by and large it's 2-bytes long, but
sometimes it can be 4 or more bytes long. How to convert? Let's see ...
for (i = 0, j = 0; i < (name_size/sizeof(name_unicode[0])); i++) {
unsigned int rune = name_unicode[i];
if (0xD7FF < rune && rune < 0xE000) {
rune = (rune & 0x7ff) << 10;
rune |= name_unicode[++i] & 0x3ff;
}
if (rune < 0x80) {
name_utf8[j++] = rune;
} else if (rune < 0x800) {
name_utf8[j++] = 0xc0 | (rune >> 6);
name_utf8[j++] = 0x80 | (rune & 0x3f);
} else if (rune < 0x10000) {
name_utf8[j++] = 0xe0 | (rune >> 12);
name_utf8[j++] = 0x80 | ((rune >> 6) & 0x3f);
name_utf8[j++] = 0x80 | (rune & 0x3f);
} else {
name_utf8[j++] = 0xf0 | (rune >> 18);
name_utf8[j++] = 0x80 | ((rune >> 12) & 0x3f);
name_utf8[j++] = 0x80 | ((rune >> 6) & 0x3f);
name_utf8[j++] = 0x80 | (rune & 0x3f);
}
}
ftp://ftp.rfc-editor.org/in-notes/rfc2279.txt
ftp://ftp.rfc-editor.org/in-notes/rfc2781.txt
Haven't even tried to compile it ...
--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
next prev parent reply other threads:[~2004-04-21 14:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-20 22:00 [PATCH] add some EFI device smarts Bjorn Helgaas
2004-04-20 23:50 ` Matt Domsch
2004-04-21 12:59 ` Bjorn Helgaas
2004-04-21 14:22 ` Matthew Wilcox [this message]
2004-04-21 7:05 ` Tolentino, Matthew E
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=20040421142228.GM18329@parcelfarce.linux.theplanet.co.uk \
--to=willy@debian.org \
--cc=Matt_Domsch@dell.com \
--cc=bjorn.helgaas@hp.com \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.e.tolentino@intel.com \
/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