Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String checkEmoticons(String name) {
        char[] chars = name.toCharArray();
        int index;
        char ch1;
        char ch2;

        index = 0;
        StringBuilder builder = new StringBuilder();
        while (index < chars.length) {
            ch1 = chars[index];
            if ((int) ch1 == 0xD83C) {
                ch2 = chars[index + 1];
                if ((int) ch2 >= 0xDF00 && (int) ch2 <= 0xDFFF) {
                    index += 2;
                    continue;
                }
            } else if ((int) ch1 == 0xD83D) {
                ch2 = chars[index + 1];
                if ((int) ch2 >= 0xDC00 && (int) ch2 <= 0xDDFF) {
                    index += 2;
                    continue;
                }
            }
            builder.append(ch1);
            ++index;
        }

        builder.trimToSize(); // remove trailing null characters
        return builder.toString();
    }
}