![]() ![]() ![]()
|
BREW C++ Class Library & GUI Framework & XML Middleware : SophiaFramework 4.1 |
The Base64 encode(B encode) and the Quoted-Printable encode(Q encode) defined in RFC2045 (MIME Part One: Format of Internet Message Bodies) are supported.
| Constructor/Destructor |
|---|
|
SFXMailField( Void ) Constructor of SFXMailField class.
|
|
~SFXMailField( Void ) Destructor of SFXMailField class.
|
| Public Functions | |
|---|---|
| SFCError |
Add(
SFXAnsiStringConstRef charset
, SFXAnsiStringConstRef text
) Add a specified string in a specified encoding to the mail header.
|
| Void |
Clear( Void ) Clear the string of the mail header.
|
| SFCError |
Decode(
SFXAnsiStringConstRef string
) Decode a specified string of the mail header.
|
| SFCError |
Encode(
SFXAnsiStringPtr string
) Encode the internal expression as the string of the mail header.
|
| CharsetTextPtr |
GetCharsetText(
SInt32 index
) Get the data in the internal expression.
|
| SInt32 |
GetSize( Void ) Get the number of fragments of the mail header in the internal expression.
|
| Protected Functions | |
|---|---|
| SFCError |
AddNonEncodedText(
ACharConstPtr start
, ACharConstPtr end
) AddNonEncodedText( SFXAnsiStringConstRef text ) Add the non-encoded character string to the mail header
|
| SFCError |
DecodeTextB(
SFXAnsiStringPtr decoded
, ACharConstPtr start
, ACharConstPtr end
) Decode the string encoded in the Base64.
|
| SFCError |
DecodeTextQ(
SFXAnsiStringPtr decoded
, ACharConstPtr start
, ACharConstPtr end
) Decode the string encoded in the Quoted-Printable.
|
| static Bool |
IsLWSP(
AChar c
) Check whether or not the character is LWSP (null, horizontal tab, line-feed or carriage return character).
|
| static Void |
SkipLWSP(
ACharConstHandle start
, ACharConstPtr end
) Advance the pointer to the character other than LWSP(null, horizontal tab, line-feed or carriage return character).
|
| Types |
|---|
|
CharsetText The internal expression of the SFXMailField class.
|
[ public, explicit ] SFXMailField(Void);
[ public ] ~SFXMailField(Void);
[ public ] SFCError Add( SFXAnsiStringConstRef charset // encoding SFXAnsiStringConstRef text // string to add );
Specify an encoding.
Specify a string to add to the mail header.
The value specified by the "charset" argument needs to be one of the strings registered to IANA such as "US-ASCII" and "ISO-2022-JP". And the string specified by the "text" argument also needs to be encoded in this encoding.
For example, when adding a string in "ISO-2022-JP" to the mail header, convert it into JIS code using the SFXMailUtility::ShiftJISToJIS function before passing it to the "text" argument.
SFXMailField::Encode example
[ protected ] SFCError AddNonEncodedText( ACharConstPtr start // pointer to the head of string to add ACharConstPtr end // pointer to the end of string to add );
[ protected ] SFCError AddNonEncodedText( SFXAnsiStringConstRef text // string to add );
Specify a string to add.
Specify a pointer to the head of string to add.
Specify a pointer to the end of string to add.
Specify a string which consists of the "US-ASCII" characters.
[ public ] Void Clear(Void);
[ public ] SFCError Decode( SFXAnsiStringConstRef string // string to be decoded );
Specify a string to be decoded.
The SFXMailField::Decode function decodes the string encoded by RFC2047 ( MIME : Message Header Extensions for Non-ASCII Text ) and convert it into the internal expression.
Each fragment of the string is maintained as a pair of "encode name and string".
To get the number of fragments, call the SFXMailField::GetSize function. And to get a fragment of the string, call the SFXMailField::GetCharsetText function.
When the character code of the mail header is "ISO-2022-JP", it needs to be converted into the Shift_JIS code. Strictly, the return value of the SFXMailField::Decode function needs to be checked.
SFXAnsiString DecodeHeader(SFXAnsiStringConstRef str) {
SFXAnsiString result;
SFXMailField decoder;
// decode
decoder.Decode(str);
for (SInt32 i = 0; i < decoder.GetSize(); ++i) {
// get the data in the internal expression
SFXMailField::CharsetTextConstPtr f = decoder.GetCharsetText(i);
if character code is JIS CODE (iso-2022-jp)
if (f->charset.Equals("iso-2022-jp", false)) {
SFXAnsiString temp;
// convert string in JIS code (iso-2022-jp) into Shift JIS code
SFXMailUtility::JISToShiftJIS(f->text, &temp, '\0');
// append it to result
result += temp;
}
else if (f->charset.Equals("us-ascii", false)) { // ascii
result += f->text;
}
else { // otherwise ... skip it
/* IMPLEMENT HERE Error Handling */
}
}
return result;
}
SFXMailField::Encode | SFXMailField::CharsetText | SFXMailField::GetSize | SFXMailField::GetCharsetText
[ protected, const ] SFCError DecodeTextB( SFXAnsiStringPtr decoded // decoded string ACharConstPtr start // pointer to the head of string to be decoded ACharConstPtr end // pointer to the end of string to be decoded );
![]() |
About Base64 encode |
|---|---|
Detailed information : RFC2045 (MIME Part One: Format of Internet Message Bodies) | |
[ protected, const ] SFCError DecodeTextQ( SFXAnsiStringPtr decoded // decoded string ACharConstPtr start // pointer to the head of string to be decoded ACharConstPtr end // pointer to the end of string to be decoded );
![]() |
About Quoted-Printable endcode |
|---|---|
Detailed information : RFC2045 (MIME Part One: Format of Internet Message Bodies) | |
[ public, const ] SFCError Encode( SFXAnsiStringPtr string // output destination );
Specify a pointer to the output destination.
Convert a string in the Shift JIS into the string of the mail header. Strictly, the return value of the SFXMailField::Encode function needs to be checked.
// after converting Shift_JIS into JIS, perform B encode // EncodeHeader function does not support ASCII string SFXAnsiString EncodeHeader(SFXAnsiStringConstRef str) { SFXAnsiString jis; SFXAnsiString result; SFXMailField encoder; // convert SJIS -> JIS SFXMailUtility::ShiftJISToJIS(str, &jis, '\0'); encoder.Add("ISO-2022-JP", jis); encoder.Encode(&result); return result; }
[ public, const ]
CharsetTextPtr GetCharsetText(
SInt32 index // index number
);Specify an index number of the internal expression.
Return the internal expression represented with the SFXMailField::CharsetText.
The SFXMailField::GetCharsetText function gets the internal expression represented with the SFXMailField::CharsetText. The index number from 0 to the return value of the SFXMailField::GetSize function can be specified .
[ public, const ] SInt32 GetSize(Void);
The number of fragments of the mail header in the internal expression.
[ protected, static ] Void SkipLWSP( ACharConstHandle start // pointer that advances ACharConstPtr end // end position );
The pointer specified by the argument advances to the character other than LWSP(null, horizontal tab, line-feed or carriage return character) or to the end position (end).
Nothing happens when the pointer is beyond the end position.
SFMTYPEDEFCLASS(CharsetText)
struct CharsetText {
SFXAnsiString charset;
SFXAnsiString text;
};
The internal expression of the SFXMailField class consists of the "charset" instance that maintains the character set and the "text" intance that maintains the data.
|
Copyright (C) 2002 - 2008 Sophia Cradle, Inc. All Rights Reserved. |
![]() ![]() ![]()
|