char [] base64 =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
void putwchar( char c )
{
if ( c == '+' )
{
putchar( '+' );
putchar( '-' );
}
else if ( c < 0x80 )
{
putchar( c );
}
else if ( c < 0x10000 )
{
putchar( '+' );
putchar( base64 [c >> 10 & 63] );
putchar( base64 [c >> 4 & 63] );
putchar( base64 [c << 2 & 63] );
putchar( '-' );
}
else if ( c < 0x110000 )
{
c = 0xD7C0DC00 + ( c >> 10 << 16 | c & 0x3FF );
putchar( '+' );
putchar( base64 [c >> 26 & 63] );
putchar( base64 [c >> 20 & 63] );
putchar( base64 [c >> 14 & 63] );
putchar( base64 [c >> 8 & 63] );
putchar( base64 [c >> 2 & 63] );
putchar( base64 [c << 4 & 63] );
putchar( '-' );
}
}