🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #39987

Re: Second newbie question: encoded Unicode strings?

#39987
From: Russ Allbery
Date: Sun, 19 Sep 1999 00:00
52 lines
2932 bytes
Bob Crispen <crispen@hiwaay.net> writes:

> Is there some public domain or GPLed C code that can translate Unicode
> character strings to something sensible?  That is, starting with

> 	=?ISO-2022-JP?B?GyRCJDckZSRDJDskLRsoQg==?=

> in, say, a Subject: line or a name= field, is there a way to convert it
> to wide characters, if there's a font that supports them on the user's
> (Win9x) machine, or to some reasonable ASCII string?

That's not Unicode.  It's ISO 2022-JP, like it says, which I think is a
JIS variation, although I could be wrong.

Anyway, the first place you should go look is RFC 2047, "Message Header
Extensions for Non-ASCII Text," which describes this in great detail,
sufficient detail to write your own implementation.  But that's just the
encoding.  Headers encoded in this form are labelled with a character set,
and when you decode them you'll then have characters in that character
set.  Obviously, you have to be able to *display* that character set, or
convert it into something you can, and that varies a lot depending on your
platform and what character set you're dealing with.

> Or if Japanese is out of the question, how about Latin-1?:

> 	=?iso-8859-1?Q?perch=E8?= no?

> which would be nice to translate to "perche no?"

perche' actually, I believe.

That's in quoted-printable rather than base64 like your previous example,
and is therefore much easier.  Search through the string for an '='
character, take the next two characters as a hex number, and output the
character corresponding to that hex code in the given character set.
Again, though, you get an ISO 8859-1 string as a result, and translating
between character sets is yet another problem.

> I found another posting that had (I believe) a JPEG file in it, but the
> entire name= string was enclosed inside the Unicode marks.  Please
> forgive the abysmal ignorance that led me to assume that this was so and
> that the file didn't simply lack a file "extension".  Is that even
> possible?  And if so, is there a way to cope with it?

I'm not sure what you're asking here, but it sounds like you'd get a lot
out of reading the entire MIME series (RFC 2045 through RFC 2049).  You
can get those from <URL:http://www.ietf.org/>, among other places.

-- 
Russ Allbery (rra@stanford.edu)         <URL:http://www.eyrie.org/~eagle/>

Technical Details
Message-ID: <yl9062f8ma.fsf@windlord.stanford.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <37E5C444.75818222@hiwaay.net>

Show Full Headers
Complete Article Headers
Message-ID: <yl9062f8ma.fsf@windlord.stanford.edu>
Subject: Re: Second newbie question: encoded Unicode strings?
Date: Sun, 19 Sep 1999 00:00:00 +0000
From: Russ Allbery <rra@stanford.edu>
References: <37E5C444.75818222@hiwaay.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 527320621
Organization: The Eyrie
Newsgroups: news.software.nntp