View mode: basic / threaded / horizontal-split · Log in · Help
February 20, 2005
mime tools for d
Any mime tools out there?  I know mango has some http stuff, but are there any
mime tools available?  By the way, I still have not gotten mango to work.
Weird.

thanks.
February 20, 2005
Re: mime tools for d
Not sure, but what are you looking for specifically?  The specs are 
pretty clear, I can't imagine it being that hard to mime, base64, etc. 
things...

For example, mime's quoted-printable would be as easy as this:

char[] generateQuotedPrintable(in char[] string, in char[] charset = 
"UTF-8")
{
	char[] output;
	bool special = false;

	char[] toHex(char value)
	{
		char[2] buffer;
	    uint i = buffer.length;

		ubyte a = value % 16, b = value / 16;

		buffer[0] = a < 10 ? a + '0' : a - 10 + 'A';
		buffer[1] = (b < 10) ? b + '0' : b - 10 + 'A';

		return buffer.dup;
	}

	for (int i = 0; i < string.length; i++)
	{
		if (string[i] < 128 && string[i] != '=' && string[i] != '?' && 
string[i] != '_')
			output ~= string[i];
		else
		{
			output ~= "=" ~ toHex(string[i]);
			i += 2;
			special = true;
		}
	}

	if (special)
		output = "=?" ~ charset ~ "?Q?" ~ output ~ "?=";

	return output;
}

Which you'd use like this:

headers ~= "Subject: " ~ generateQuotedPrintable(subject) ~ "\r\n";

PS: The toHex in there is just a workaround for a problem in std.string.

-[Unknown]


> Any mime tools out there?  I know mango has some http stuff, but are there any
> mime tools available?  By the way, I still have not gotten mango to work.
> Weird.
> 
> thanks.
> 
>
February 20, 2005
Re: mime tools for d
What trouble have you had with Mango?  Its generally /very/ easy to get 
started with, so it may be something simple.  Or a new bug that needs 
addressing.

Kris: Maybe we should start a Mango.net.* Branch for things like mime?

-- Chris S

jicman wrote:
> Any mime tools out there?  I know mango has some http stuff, but are there any
> mime tools available?  By the way, I still have not gotten mango to work.
> Weird.
Top | Discussion index | About this forum | D home