本文整理汇总了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;
}
}
示例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();
}
示例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);
}
}
}
}
示例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;
}
}
示例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;
}
示例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);
}
示例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", "");
}
示例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);
}
示例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);
}
示例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;
}
示例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'; // '』'
}
示例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'; // '』'
}
示例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();
}
示例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;
}
示例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);
}
}