Thread View: news.software.nntp
3 messages
3 total messages
Started by Bob Crispen
Mon, 20 Sep 1999 00:00
Second newbie question: encoded Unicode strings?
Author: Bob Crispen
Date: Mon, 20 Sep 1999 00:00
Date: Mon, 20 Sep 1999 00:00
40 lines
2224 bytes
2224 bytes
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? 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?" In fact, since the program I'm writing is inextricably tied to Win9x by now, I could even print that with the system fonts if I knew how to do the translation (e.g., what the Q and B stand for, and what other things I might expect to find). At any rate, I've noticed that many newsreaders do not render the ISO strings as I've just done above but do something to convert them, and I'd like to do the same thing if I can. Even a pointer to a document would help. 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? -- Bob Crispen crispen at hiwaay dot net What we're looking for: destinations. What we end up getting: journeys.
Re: Second newbie question: encoded Unicode strings?
Author: Russ Allbery
Date: Sun, 19 Sep 1999 00:00
Date: Sun, 19 Sep 1999 00:00
52 lines
2932 bytes
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/>
Re: Second newbie question: encoded Unicode strings?
Author: greg andruk
Date: Mon, 20 Sep 1999 00:00
Date: Mon, 20 Sep 1999 00:00
29 lines
1679 bytes
1679 bytes
Bob Crispen <crispen@hiwaay.net> wrote: > 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, but a Q-encoded header (You will sometimes see Unicode in these beasts, where something like UTF-8 appears instead of the ISO charset). See RFC 2047 and its predecessor, RFC 1522. The B and Q encodings are nothing more than Base64 and slightly tweaked quoted-printable. The ISO charsets have the same mappings as used in the MIME Content-Type header. > Or if Japanese is out of the question, how about Latin-1?: > =?iso-8859-1?Q?perch=E8?= no? Same thing. You can find some GPL'd sample code to do this in slrn, but any MIME library should handle this.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads