Android™
Android™
Q-Encode a String for MIME Headers
See more Email Object Examples
Demonstrates the Chilkat Email.QEncodeString method, which converts the Unicode string in the first argument to the charset named in the second argument, Q-encodes the resulting multibyte data, and returns the encoded string. This is one of the representations used for non-ASCII text in MIME header fields.
Background: RFC 2047 defines two "encoded-word" schemes for putting non-ASCII text in headers: B (Base64) and Q (quoted-printable-style). Q-encoding leaves plain ASCII mostly readable and escapes only the special bytes, producing output like
=?utf-8?Q?Caf=C3=A9?=. It is the better choice when text is mostly ASCII with a few accented characters, whereas B-encoding (BEncodeString) is more compact when most characters are non-ASCII.Chilkat Android™ Downloads
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;
import android.app.Activity;
import com.chilkatsoft.*;
import android.widget.TextView;
import android.os.Bundle;
public class SimpleActivity extends Activity {
private static final String TAG = "Chilkat";
// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Demonstrates the QEncodeString method, which converts a Unicode string to a specified
// charset, Q-encodes (RFC 2047) the resulting bytes, and returns the encoded string.
// This is one of the forms used for non-ASCII text in MIME header fields.
CkEmail email = new CkEmail();
// Q-encode a Unicode string using the utf-8 charset.
String encoded = email.qEncodeString("Cafe Meeting Notes","utf-8");
Log.i(TAG, "Q-encoded: " + encoded);
}
static {
System.loadLibrary("chilkat");
// Note: If the incorrect library name is passed to System.loadLibrary,
// then you will see the following error message at application startup:
//"The application <your-application-name> has stopped unexpectedly. Please try again."
}
}