Home | History | Annotate | Download | only in common
      1 /*
      2  * Copyright (C) 2015 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License
     15  */
     16 
     17 package com.android.inputmethod.latin.common;
     18 
     19 /**
     20  * Emojis are supplementary characters expressed as a low+high pair. For instance,
     21  * the emoji U+1F625 is encoded as "\uD83D\uDE25" in UTF-16, where '\uD83D' is in
     22  * the range of [0xd800, 0xdbff] and '\uDE25' is in the range of [0xdc00, 0xdfff].
     23  * {@see http://docs.oracle.com/javase/6/docs/api/java/lang/Character.html#unicode}
     24  */
     25 public final class UnicodeSurrogate {
     26     private static final char LOW_SURROGATE_MIN = '\uD800';
     27     private static final char LOW_SURROGATE_MAX = '\uDBFF';
     28     private static final char HIGH_SURROGATE_MIN = '\uDC00';
     29     private static final char HIGH_SURROGATE_MAX = '\uDFFF';
     30 
     31     public static boolean isLowSurrogate(final char c) {
     32         return c >= LOW_SURROGATE_MIN && c <= LOW_SURROGATE_MAX;
     33     }
     34 
     35     public static boolean isHighSurrogate(final char c) {
     36         return c >= HIGH_SURROGATE_MIN && c <= HIGH_SURROGATE_MAX;
     37     }
     38 }
     39