當前位置: 首頁>>代碼示例>>Java>>正文


Java UnicodeBlock類代碼示例

本文整理匯總了Java中java.lang.Character.UnicodeBlock的典型用法代碼示例。如果您正苦於以下問題:Java UnicodeBlock類的具體用法?Java UnicodeBlock怎麽用?Java UnicodeBlock使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


UnicodeBlock類屬於java.lang.Character包,在下文中一共展示了UnicodeBlock類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addAlphabet

import java.lang.Character.UnicodeBlock; //導入依賴的package包/類
private static void addAlphabet(Object base,
		Character.UnicodeBlock[] alphabet, String language)
		throws ResourceParseException, IOException {
	boolean b = false;
	for (int i = 0; !b && i < alphabet.length; i++) {
		b = loadedAlphabets.contains(alphabet[i]) || b;
	}
	if (!b) {
		TeXParser.isLoading = true;
		addTeXFontDescription(base,
				AjLatexMath.getAssetManager().open(language), language);
		for (int i = 0; i < alphabet.length; i++) {
			loadedAlphabets.add(alphabet[i]);
		}
		TeXParser.isLoading = false;
	}
}
 
開發者ID:daquexian,項目名稱:FlexibleRichTextView,代碼行數:18,代碼來源:DefaultTeXFont.java

示例2: removeDiacritics

import java.lang.Character.UnicodeBlock; //導入依賴的package包/類
/**
 * Remove diacritics from the specified string.
 * @param s
 * @return a copy of the specified string with diacritics removed.
 */
public static final String removeDiacritics(String s) {
	String n = Normalizer.normalize(s, Form.NFD);
	StringBuilder sb = null;
	for (int i = 0; i < n.length(); ++i) {
		char c = n.charAt(i);
		UnicodeBlock b = UnicodeBlock.of(c);
		if (UnicodeBlock.COMBINING_DIACRITICAL_MARKS.equals(b) || UnicodeBlock.COMBINING_DIACRITICAL_MARKS_SUPPLEMENT.equals(b)) {
			if (sb == null) {
				sb = new StringBuilder(n.length());
				sb.append(n.substring(0, i));
			}
			continue;
		}
		if (sb != null)
			sb.append(c);
	}
	if (sb == null)
		return n;
	return sb.toString();
}
 
開發者ID:Bibliome,項目名稱:bibliome-java-utils,代碼行數:26,代碼來源:Strings.java

示例3: initGlyphRenderer

import java.lang.Character.UnicodeBlock; //導入依賴的package包/類
protected void initGlyphRenderer() 
{
	glyphRendererBlocks = new HashSet<Character.UnicodeBlock>();
	List<PropertySuffix> props = propertiesUtil.getAllProperties(getCurrentJasperPrint(), 
			PdfReportConfiguration.PROPERTY_PREFIX_GLYPH_RENDERER_BLOCKS);
	for (PropertySuffix prop : props)
	{
		String blocks = prop.getValue();
		for (String blockToken : blocks.split(","))
		{
			UnicodeBlock block = resolveUnicodeBlock(blockToken);
			if (block != null)
			{
				if (log.isDebugEnabled())
				{
					log.debug("glyph renderer block " + block);
				}
				glyphRendererBlocks.add(block);
			}
		}
	}
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:23,代碼來源:JRPdfExporter.java

示例4: resolveUnicodeBlock

import java.lang.Character.UnicodeBlock; //導入依賴的package包/類
protected UnicodeBlock resolveUnicodeBlock(String name)
{
	if (name.trim().isEmpty())
	{
		return null;
	}
	
	try 
	{
		return UnicodeBlock.forName(name.trim());
	} 
	catch (IllegalArgumentException e) 
	{
		log.warn("Could not resolve \"" + name + "\" to a Unicode block");
		return null;
	} 
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:18,代碼來源:JRPdfExporter.java

示例5: parseWithType

import java.lang.Character.UnicodeBlock; //導入依賴的package包/類
public List<Pair<Character, UnitType>> parseWithType(String str) {
    List<Pair<Character, UnitType>> result = new ArrayList<>();

    int length = str.length();
    for (int i = 0; i < length; i++) {
        char ch = str.charAt(i);
        Character.UnicodeBlock block = Character.UnicodeBlock.of(ch);
        if (block == UnicodeBlock.HANGUL_SYLLABLES) {
            int cho, jung, jong, tmp;
            tmp = ch - 0xAC00;
            cho = tmp / (21 * 28);
            tmp = tmp % (21 * 28);
            jung = tmp / 28;
            jong = tmp % 28;
            result.add(new Pair<>(ChoSung[cho], UnitType.CHOSUNG));
            result.add(new Pair<>(JungSung[jung], UnitType.JUNGSUNG));
            if (jong != 0) {
                result.add(new Pair<>(JongSung[jong], UnitType.JONGSUNG));
            }
        } else {
            result.add(new Pair<>(ch, UnitType.OTHER));
        }
    }
    return result;
}
 
開發者ID:shin285,項目名稱:KOMORAN,代碼行數:26,代碼來源:KoreanUnitParser.java

示例6: isRussianWord

import java.lang.Character.UnicodeBlock; //導入依賴的package包/類
public static boolean isRussianWord(String token) {
    if (token.isEmpty()) {
        return false;
    }
    Character lastLetter = null;
    // find last letter
    for (int i = token.length() - 1; i >= 0; i--) {
        char ch = token.charAt(i);
        if (Character.isLetter(ch)) {
            lastLetter = ch;
            break;
        }
    }
    if (lastLetter == null) {
        return false;
    }
    // check is it cyrillic
    return UnicodeBlock.of(lastLetter).equals(UnicodeBlock.CYRILLIC);
}
 
開發者ID:textocat,項目名稱:textokit-core,代碼行數:20,代碼來源:WordUtils.java

示例7: utf8ToUnicode

import java.lang.Character.UnicodeBlock; //導入依賴的package包/類
/**
 * utf-8 轉unicode
 *
 * @param inStr
 * @return String
 */
public static String utf8ToUnicode(String inStr) {
    char[] myBuffer = inStr.toCharArray();
 
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < inStr.length(); i++) {
        UnicodeBlock ub = UnicodeBlock.of(myBuffer[i]);
        if (ub == UnicodeBlock.BASIC_LATIN) {
            sb.append(myBuffer[i]);
        } else if (ub == UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
            int j = (int) myBuffer[i] - 65248;
            sb.append((char) j);
        } else {
            short s = (short) myBuffer[i];
            String hexS = Integer.toHexString(s);
            String unicode = "\\u" + hexS;
            sb.append(unicode.toLowerCase());
        }
    }
    return sb.toString().replaceAll("ffff", "");
}
 
開發者ID:AndroidStudioTranslate,項目名稱:Android-Studio-Translate-Tool,代碼行數:27,代碼來源:WordsTransfer.java

示例8: isChinese

import java.lang.Character.UnicodeBlock; //導入依賴的package包/類
public boolean isChinese(char c) {
		Set<UnicodeBlock> chineseUnicodeBlocks = new HashSet<UnicodeBlock>();
		chineseUnicodeBlocks.add(UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS);
//			add(UnicodeBlock.CJK_COMPATIBILITY);
//			add(UnicodeBlock.CJK_COMPATIBILITY_FORMS);
//			add(UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS);
//			add(UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT);
//			add(UnicodeBlock.CJK_RADICALS_SUPPLEMENT);
//			add(UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION);
//			add(UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS);
//			add(UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A);
//			add(UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B);
//			add(UnicodeBlock.KANGXI_RADICALS);
//			add(UnicodeBlock.IDEOGRAPHIC_DESCRIPTION_CHARACTERS);
		
		UnicodeBlock block = UnicodeBlock.of(c);
		return chineseUnicodeBlocks.contains(block);
	}
 
開發者ID:donkirkby,項目名稱:donkirkby,代碼行數:19,代碼來源:CharacterClassifier.java

示例9: normalizeCharacter

import java.lang.Character.UnicodeBlock; //導入依賴的package包/類
public static String normalizeCharacter(int codePoint) {
  if (!Character.isValidCodePoint(codePoint)) {
    return "";
  }

  // TODO: long search? maybe replace with own implementation
  UnicodeBlock block = Character.UnicodeBlock.of(codePoint);
  if (block == Character.UnicodeBlock.MATHEMATICAL_ALPHANUMERIC_SYMBOLS) {
    return normalizeMath(codePoint);
  }

  if (block == Character.UnicodeBlock.LETTERLIKE_SYMBOLS) {
    return normalizeLetterLike(codePoint);
  }

  return codePointToString(codePoint);
}
 
開發者ID:ag-gipp,項目名稱:mathosphere,代碼行數:18,代碼來源:UnicodeUtils.java

示例10: tokenize

import java.lang.Character.UnicodeBlock; //導入依賴的package包/類
@Override
public List<String> tokenize(String text) {
	int beginIndex = -1;
	UnicodeBlock current = null;
	List<String> list = new LinkedList<>();
	for (int i = 0; i < text.length(); i++) {
		UnicodeBlock block = UnicodeBlock.of(text.charAt(i));
		if (current != block) {
			if (beginIndex >= 0) {
				list.add(text.substring(beginIndex, i));
			}
			beginIndex = i;
			current = block;
		}
	}
	if (beginIndex >= 0) {
		list.add(text.substring(beginIndex));
	}
	return list;
}
 
開發者ID:agwlvssainokuni,項目名稱:sqlapp,代碼行數:21,代碼來源:UnicodeBlockTokenizer.java

示例11: isFullHiragana

import java.lang.Character.UnicodeBlock; //導入依賴的package包/類
/**
 * 文字種判別「全角ひらがな」。
 * 
 * @param codePoint 対象文字 (コードポイントで指定すること)。
 * @return 対象文字が「全角ひらがな」であれば真(true)、さもなくば、偽(false)。
 */
public static boolean isFullHiragana(int codePoint) {
	// based on Unicode 3.2
	return of(codePoint) == UnicodeBlock.HIRAGANA || // \u3040 - \u309F
			// import from KATAKANA (\u30A0 - \u30FF)
			codePoint == '\u30A0' || // '゠' from KATAKANA (not in Win31J)
			codePoint == '\u30FB' || // '・' from KATAKANA
			codePoint == '\u30FC' || // 'ー' from KATAKANA
			// \u30FD 'ヽ' and \u30FE 'ヾ' if iteration mark for KATAKANA
			codePoint == '\u30FF' || // 'ヿ' from KATAKANA (not in Win31J)
			codePoint == '\u3001' || // '、'
			codePoint == '\u3002' || // '。'
			codePoint == '\u300C' || // '「'
			codePoint == '\u300D' || // '」'
			codePoint == '\u300E' || // '『'
			codePoint == '\u300F'; // '』'
}
 
開發者ID:agwlvssainokuni,項目名稱:sqlapp,代碼行數:23,代碼來源:CharTypeValidator.java

示例12: isFullKatakana

import java.lang.Character.UnicodeBlock; //導入依賴的package包/類
/**
 * 文字種判別「全角カタカナ」。
 * 
 * @param codePoint 対象文字 (コードポイントで指定すること)。
 * @return 対象文字が「全角カタカナ」であれば真(true)、さもなくば、偽(false)。
 */
public static boolean isFullKatakana(int codePoint) {
	// based on Unicode 3.2
	return of(codePoint) == UnicodeBlock.KATAKANA || // \u30A0 - \u30FF
			of(codePoint) == UnicodeBlock.KATAKANA_PHONETIC_EXTENSIONS || // \u31F0-\u31FF
			// import from HIRAGANA (\u3040 - \u309F)
			// \u3040, \u3097, \u3098 is reserved
			codePoint == '\u3099' || // MARK from HIRAGANA (not in Win31J)
			codePoint == '\u309A' || // MARK from HIRAGANA (not in Win31J)
			codePoint == '\u309B' || // '゛' from HIRAGANA
			codePoint == '\u309C' || // '゜' from HIRAGANA
			// \u309D 'ゝ' and \u309E 'ゞ' is iteration mark for HIRAGANA
			codePoint == '\u309F' || // 'ゟ' from HIRAGANA (not in Win31J)
			codePoint == '\u3001' || // '、'
			codePoint == '\u3002' || // '。'
			codePoint == '\u300C' || // '「'
			codePoint == '\u300D' || // '」'
			codePoint == '\u300E' || // '『'
			codePoint == '\u300F'; // '』'
}
 
開發者ID:agwlvssainokuni,項目名稱:sqlapp,代碼行數:26,代碼來源:CharTypeValidator.java

示例13: utf8ToUnicode

import java.lang.Character.UnicodeBlock; //導入依賴的package包/類
/**
 * utf-8 轉換成 unicode
 *
 * @param inStr
 * @return
 * @author fanhui
 * 2007-3-15
 */
public static String utf8ToUnicode(String inStr) {
    char[] myBuffer = inStr.toCharArray();

    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < inStr.length(); i++) {
        UnicodeBlock ub = UnicodeBlock.of(myBuffer[i]);
        if (ub == UnicodeBlock.BASIC_LATIN) {
            //英文及數字等
            sb.append(myBuffer[i]);
        } else if (ub == UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
            //全角半角字符
            int j = (int) myBuffer[i] - 65248;
            sb.append((char) j);
        } else {
            //漢字
            short s = (short) myBuffer[i];
            String hexS = Integer.toHexString(s);
            String unicode = "\\u" + hexS;
            sb.append(unicode.toLowerCase());
        }
    }
    return sb.toString();
}
 
開發者ID:blademainer,項目名稱:common_utils,代碼行數:32,代碼來源:UnicodeHelper.java

示例14: of

import java.lang.Character.UnicodeBlock; //導入依賴的package包/類
static public TTUnicodeRange of(long a_unicode) {
    initList();

    TTUnicodeRange retval = null;
    UnicodeBlock block = UnicodeBlock.of((int) a_unicode);
    if (block == null) {
        return retval;
    }

    int i;
    for (i = 0; i < s_list.size(); i++) {
        TTUnicodeRange range = s_list.get(i);
        if (range.m_block.equals(block)) {
            return range;
        }
    }

    return retval;
}
 
開發者ID:jindrapetrik,項目名稱:jpexs-decompiler,代碼行數:20,代碼來源:TTUnicodeRange.java

示例15: get

import java.lang.Character.UnicodeBlock; //導入依賴的package包/類
/**
 * Creates a {@link GlyphProducer} based on a range of characters.
 *
 * @param font Style of text
 * @param rd Controller of rendering details
 * @param frc Details on how fonts are rendered
 * @param ub Range of characters to support
 * @return Correct glyph producer for unicode block, not null
 * @throws NullPointerException if font, render delegate, or render context is null
 */
/*@Nonnull*/
public static GlyphProducer get(/*@Nonnull*/ final Font font,
                                /*@Nonnull*/ final RenderDelegate rd,
                                /*@Nonnull*/ final FontRenderContext frc,
                                /*@CheckForNull*/ final UnicodeBlock ub) {

    Check.notNull(font, "Font cannot be null");
    Check.notNull(rd, "Render delegate cannot be null");
    Check.notNull(frc, "Font render context cannot be null");

    if (ub == UnicodeBlock.BASIC_LATIN) {
        return new AsciiGlyphProducer(font, rd, frc);
    } else {
        return new UnicodeGlyphProducer(font, rd, frc);
    }
}
 
開發者ID:jedwards1211,項目名稱:breakout,代碼行數:27,代碼來源:GlyphProducers.java


注:本文中的java.lang.Character.UnicodeBlock類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。