MMS彩信字符集(字符编码)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MMS彩信字符集(字符编码)相关的知识,希望对你有一定的参考价值。

彩信字符集在CharacterSets类中定义

android\frameworks\opt\telephony\src\java\com\google\android\mms\pdu\CharacterSets.java

public class CharacterSets {
    /**
     * IANA assigned MIB enum numbers.
     *
     * From wap-230-wsp-20010705-a.pdf
     * Any-charset = <Octet 128>
     * Equivalent to the special RFC2616 charset value "*"
     */
    public static final int ANY_CHARSET = 0x00;
    public static final int US_ASCII    = 0x03;
    public static final int ISO_8859_1  = 0x04;
    public static final int ISO_8859_2  = 0x05;
    public static final int ISO_8859_3  = 0x06;
    public static final int ISO_8859_4  = 0x07;
    public static final int ISO_8859_5  = 0x08;
    public static final int ISO_8859_6  = 0x09;
    public static final int ISO_8859_7  = 0x0A;
    public static final int ISO_8859_8  = 0x0B;
    public static final int ISO_8859_9  = 0x0C;
    public static final int SHIFT_JIS   = 0x11;
    public static final int UTF_8       = 0x6A;
    public static final int BIG5        = 0x07EA;
    public static final int UCS2        = 0x03E8;
    public static final int UTF_16      = 0x03F7;

    /**
     * If the encoding of given data is unsupported, use UTF_8 to decode it.
     */
    public static final int DEFAULT_CHARSET = UTF_8;  //------------ 默认字符编码 utf-8 -----------


   /**
     * The Well-known-charset Mime name.
     */
    public static final String MIMENAME_ANY_CHARSET = "*";
    public static final String MIMENAME_US_ASCII    = "us-ascii";
    public static final String MIMENAME_ISO_8859_1  = "iso-8859-1";
    public static final String MIMENAME_ISO_8859_2  = "iso-8859-2";
    public static final String MIMENAME_ISO_8859_3  = "iso-8859-3";
    public static final String MIMENAME_ISO_8859_4  = "iso-8859-4";
    public static final String MIMENAME_ISO_8859_5  = "iso-8859-5";
    public static final String MIMENAME_ISO_8859_6  = "iso-8859-6";
    public static final String MIMENAME_ISO_8859_7  = "iso-8859-7";
    public static final String MIMENAME_ISO_8859_8  = "iso-8859-8";
    public static final String MIMENAME_ISO_8859_9  = "iso-8859-9";
    public static final String MIMENAME_SHIFT_JIS   = "shift_JIS";
    public static final String MIMENAME_UTF_8       = "utf-8";
    public static final String MIMENAME_BIG5        = "big5";
    public static final String MIMENAME_UCS2        = "iso-10646-ucs-2";
    public static final String MIMENAME_UTF_16      = "utf-16";

    public static final String DEFAULT_CHARSET_NAME = MIMENAME_UTF_8;

再看看MMS发送代码中的处理

android\packages\apps\Mms\src\com\android\mms\transaction\HttpUtils.java

private static AndroidHttpClient createHttpClient(Context context) {
        String userAgent = MmsConfig.getUserAgent();
        AndroidHttpClient client = AndroidHttpClient.newInstance(userAgent, context);
        HttpParams params = client.getParams();
        HttpProtocolParams.setContentCharset(params, "UTF-8"); //-------- 默认 UTF-8 ----------
// set the socket timeout int soTimeout = MmsConfig.getHttpSocketTimeout(); if (Log.isLoggable(LogTag.TRANSACTION, Log.DEBUG)) { Log.d(TAG, "[HttpUtils] createHttpClient w/ socket timeout " + soTimeout + " ms, " + ", UA=" + userAgent); } HttpConnectionParams.setSoTimeout(params, soTimeout); return client; }

还有彩信数据TextModel封装处理

android\packages\apps\Mms\src\com\android\mms\model\TextModel.java

    public TextModel(Context context, String contentType, String src, RegionModel region) {
        this(context, contentType, src, CharacterSets.UTF_8, new byte[0], region); //------ 默认 UTF-8 ------
    }

    public TextModel(Context context, String contentType, String src,
            int charset, byte[] data, RegionModel region) {
        super(context, SmilHelper.ELEMENT_TAG_TEXT, contentType, src,
                data != null ? data : new byte[0], region);

        if (charset == CharacterSets.ANY_CHARSET) { //--- 对于这种指定编码的,如果为ANY_CHARSET,则默认ISO_8859_1
            // By default, we use ISO_8859_1 to decode the data
            // which character set wasn‘t set.
            charset = CharacterSets.ISO_8859_1;
        }
        mCharset = charset;
        mText = extractTextFromData(data);
        mSize = mText.toString().getBytes().length;
    }

 

以上是关于MMS彩信字符集(字符编码)的主要内容,如果未能解决你的问题,请参考以下文章

我想要来自 android 中 MMS db 的彩信号码、发送/接收、正文和附件详细信息...怎么做?

手机端ios和android浏览器 如何实现mms广播电台在线音频播放?

一条SMS最大字符数,字符数达到多少按MMS处理

msmms sms与mms 简述!

PHP-彩信集成参考网址-SMSGlobal.com网站

有没有办法使用 curl 或 wget 从命令行下载彩信?