This is iso88591hack.c in view mode; [Download] [Up]
#import <string.h>
#import <stdio.h>
// This is a hack. The proper place for this kind of translation is probably NNTP.m
#import "iso88591hack.h"
#import "iso2next.tab" // includes table (twice. NNTP.m does so too.) Yuck!
// Hack =?ISO-8859-1?Q? ... =XX ... ?= translations, in-place.
void iso_8859_1_hack(char *buf)
{
static char iso_8859_1_Q[] = "=?ISO-8859-1?Q?";
char *s = strchr(buf, '='), *t;
if (s == NULL) return;
if (strncasecmp(s, iso_8859_1_Q, sizeof(iso_8859_1_Q)-1) != 0) return;
strcpy(s, s + sizeof(iso_8859_1_Q)-1);
for (; (t = strchr(s, '=')) != 0; s = t)
{
if (t > s && t[-1] == '?')
{
// ?= is end quote.
strcpy(t-1, t+1);
break;
}
else
{
// parse "=XX" where XX is a 2-digit hex number
unsigned c = 0;
sscanf(t+1, "%2x", &c);
if (c < CHARNUM && c_iso2next[c] != 0)
{
*t = c_iso2next[c];
strcpy(t+1, t+3);
}
++t;
}
}
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.