Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 *  Copyright (c) 2013 The CCP project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a Beijing Speedtong Information Technology Co.,Ltd license
 *  that can be found in the LICENSE file in the root of the web site.
 *
 *   http://www.yuntongxun.com
 *
 *  An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

import android.text.TextUtils;

public class Main {
    /**
     * Replace the not support emoji.
     * @param str
     * @return
     */
    public static String matchEmojiUnicode(String str) {
        if (TextUtils.isEmpty(str)) {
            return str;
        }
        char[] charArray = str.toCharArray();
        try {
            for (int i = 0; i < charArray.length - 1; i++) {
                int _index = charArray[i];
                int _index_inc = charArray[i + 1];

                if (_index == 55356) {
                    if ((_index_inc < 56324) || (_index_inc > 57320)) {
                        continue;
                    }
                    charArray[i] = '.';
                    charArray[(i + 1)] = '.';
                    continue;
                }

                if ((_index != 55357) || (_index_inc < 56343) || (_index_inc > 57024)) {
                    continue;
                }

                charArray[i] = '.';
                charArray[(i + 1)] = '.';
            }
        } catch (Exception e) {
        }

        return new String(charArray);
    }
}