First of all, I'm here to correct my mistakes in a mistake: Base64 is just a MIME encoding scheme, and my original MIME is actually another coding scheme for MIME--quoted-printable, so I've made some corrections to this article, And I apologise for the misleading that has been brought to you. May.6-01
Recently in the study of POP3 encountered a problem, that the Chinese are MIME-encoded, such as MS Outlook Express is using Base64, and FoxMail is QP, was looking for a few ready-made coding/decoding code, the result only in the UDDF to find a A Delphi Base64 Decode, although Uddf said is Encode/decode, but I did not find encode part, and write well, had to write a.
This code is a BCB unit, very simple, providing four functions, to be converted to Delphi or other C + + is also very easy, the need for their own change it. This code has been tested and the results are correct.
Add: Because not long ago, a friend with VC in quoting this code came up against some difficulties, due to the particularity of the BCB ansistring, so I rewrite this code as standard C, it should be like this, but I used to use the ansistring so just write like that, But now I have to rewrite it. But in order to facilitate the use of DELPHI/BCB, I still specifically added some dongdong, see the program's comments, the purpose is to better use some other languages, please refer to it. Mar.31-01
Add: In order to make this procedure more practical, I will organize it into several units, respectively, for Delphi and C++builder. Includes processing of data flow tmemorystream and strings. Can be downloaded from the site works. Aug.14-01
FIX: Because not long ago a netizen sent me Mail said he was using some code to decode the message attachment error, I checked and found that my decoding function can only handle consecutive strings, and general mail attachment is a string with carriage return, so I made a little correction, see the following comments. apr.03-02
The following is a header file:
//---------------------------------------------------------------------------
// MIME(QP & Base64) Encode/Decode unit. (H)
// Copyright (c) 2000, 02 Mental Studio - http://mental.mentsu.com
// Author : Raptor - raptorz@163.com
//---------------------------------------------------------------------------
#ifndef mimeb64H
#define mimeb64H
//---------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif
int QPEncode( char * const aDest, const unsigned char * aSrc, int aLen );
int QPDecode( unsigned char * const aDest, const char * aSrc );
int Base64Encode( char * const aDest, const unsigned char * aSrc, int aLen );
int Base64Decode( unsigned char * const aDest, const char * aSrc );
#ifdef __cplusplus
}
#endif
//---------------------------------------------------------------------------
#endif