当前位置: 首页>>代码示例>>Java>>正文


Java UCharacter.hasBinaryProperty方法代码示例

本文整理汇总了Java中com.ibm.icu.lang.UCharacter.hasBinaryProperty方法的典型用法代码示例。如果您正苦于以下问题:Java UCharacter.hasBinaryProperty方法的具体用法?Java UCharacter.hasBinaryProperty怎么用?Java UCharacter.hasBinaryProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ibm.icu.lang.UCharacter的用法示例。


在下文中一共展示了UCharacter.hasBinaryProperty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNFKCDataFilesFromIcuProject

import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
private static void getNFKCDataFilesFromIcuProject() throws IOException {
  URL icuTagsURL = new URL(ICU_SVN_TAG_URL + "/");
  URL icuReleaseTagURL = new URL(icuTagsURL, ICU_RELEASE_TAG + "/");
  URL norm2url = new URL(icuReleaseTagURL, ICU_DATA_NORM2_PATH + "/");

  System.err.print("Downloading " + NFKC_TXT + " ... ");
  download(new URL(norm2url, NFKC_TXT), NFKC_TXT);
  System.err.println("done.");
  System.err.print("Downloading " + NFKC_CF_TXT + " ... ");
  download(new URL(norm2url, NFKC_CF_TXT), NFKC_CF_TXT);
  System.err.println("done.");

  System.err.print("Downloading " + NFKC_CF_TXT + " and making diacritic rules one-way ... ");
  URLConnection connection = openConnection(new URL(norm2url, NFC_TXT));
  BufferedReader reader = new BufferedReader
      (new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
  Writer writer = new OutputStreamWriter(new FileOutputStream(NFC_TXT), StandardCharsets.UTF_8);
  try {
    String line;

    while (null != (line = reader.readLine())) {
      Matcher matcher = ROUND_TRIP_MAPPING_LINE_PATTERN.matcher(line);
      if (matcher.matches()) {
        final String leftHandSide = matcher.group(1);
        final String rightHandSide = matcher.group(2).trim();
        List<String> diacritics = new ArrayList<>();
        for (String outputCodePoint : rightHandSide.split("\\s+")) {
          int ch = Integer.parseInt(outputCodePoint, 16);
          if (UCharacter.hasBinaryProperty(ch, UProperty.DIACRITIC)
              // gennorm2 fails if U+0653-U+0656 are included in round-trip mappings
              || (ch >= 0x653 && ch <= 0x656)) {
            diacritics.add(outputCodePoint);
          }
        }
        if ( ! diacritics.isEmpty()) {
          StringBuilder replacementLine = new StringBuilder();
          replacementLine.append(leftHandSide).append(">").append(rightHandSide);
          replacementLine.append("  # one-way: diacritic");
          if (diacritics.size() > 1) {
            replacementLine.append("s");
          }
          for (String diacritic : diacritics) {
            replacementLine.append(" ").append(diacritic);
          }
          line = replacementLine.toString();
        }
      }
      writer.write(line);
      writer.write("\n");
    }
  } finally {
    reader.close();
    writer.close();
  }
  System.err.println("done.");
}
 
开发者ID:europeana,项目名称:search,代码行数:57,代码来源:GenerateUTR30DataFiles.java

示例2: getNFKCDataFilesFromIcuProject

import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
private static void getNFKCDataFilesFromIcuProject() throws IOException {
  URL icuTagsURL = new URL(ICU_SVN_TAG_URL + "/");
  URL icuReleaseTagURL = new URL(icuTagsURL, ICU_RELEASE_TAG + "/");
  URL norm2url = new URL(icuReleaseTagURL, ICU_DATA_NORM2_PATH + "/");

  System.err.print("Downloading " + NFKC_TXT + " ... ");
  download(new URL(norm2url, NFKC_TXT), NFKC_TXT);
  System.err.println("done.");
  System.err.print("Downloading " + NFKC_CF_TXT + " ... ");
  download(new URL(norm2url, NFKC_CF_TXT), NFKC_CF_TXT);
  System.err.println("done.");

  System.err.print("Downloading " + NFKC_CF_TXT + " and making diacritic rules one-way ... ");
  URLConnection connection = openConnection(new URL(norm2url, NFC_TXT));
  BufferedReader reader = new BufferedReader
      (new InputStreamReader(connection.getInputStream(), "UTF-8"));
  Writer writer = new OutputStreamWriter(new FileOutputStream(NFC_TXT), "UTF-8");
  try {
    String line;

    while (null != (line = reader.readLine())) {
      Matcher matcher = ROUND_TRIP_MAPPING_LINE_PATTERN.matcher(line);
      if (matcher.matches()) {
        final String leftHandSide = matcher.group(1);
        final String rightHandSide = matcher.group(2).trim();
        List<String> diacritics = new ArrayList<String>();
        for (String outputCodePoint : rightHandSide.split("\\s+")) {
          int ch = Integer.parseInt(outputCodePoint, 16);
          if (UCharacter.hasBinaryProperty(ch, UProperty.DIACRITIC)
              // gennorm2 fails if U+0653-U+0656 are included in round-trip mappings
              || (ch >= 0x653 && ch <= 0x656)) {
            diacritics.add(outputCodePoint);
          }
        }
        if ( ! diacritics.isEmpty()) {
          StringBuilder replacementLine = new StringBuilder();
          replacementLine.append(leftHandSide).append(">").append(rightHandSide);
          replacementLine.append("  # one-way: diacritic");
          if (diacritics.size() > 1) {
            replacementLine.append("s");
          }
          for (String diacritic : diacritics) {
            replacementLine.append(" ").append(diacritic);
          }
          line = replacementLine.toString();
        }
      }
      writer.write(line);
      writer.write("\n");
    }
  } finally {
    reader.close();
    writer.close();
  }
  System.err.println("done.");
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:57,代码来源:GenerateUTR30DataFiles.java

示例3: getNFKCDataFilesFromIcuProject

import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
private static void getNFKCDataFilesFromIcuProject(String dir) throws IOException {
    URL icuTagsURL = new URL(ICU_SVN_TAG_URL + "/");
    URL icuReleaseTagURL = new URL(icuTagsURL, ICU_RELEASE_TAG + "/");
    URL norm2url = new URL(icuReleaseTagURL, ICU_DATA_NORM2_PATH + "/");
    logger.info("Downloading " + NFKC_TXT + " ... ");
    download(new URL(norm2url, NFKC_TXT), dir + NFKC_TXT);
    logger.info("done.");
    logger.info("Downloading " + NFKC_CF_TXT + " ... ");
    download(new URL(norm2url, NFKC_CF_TXT), dir + NFKC_CF_TXT);
    logger.info("done.");
    logger.info("Downloading " + NFKC_CF_TXT + " and making diacritic rules one-way ... ");
    URLConnection connection = openConnection(new URL(norm2url, NFC_TXT));
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(),
            StandardCharsets.UTF_8));
         Writer writer = new OutputStreamWriter(new FileOutputStream(dir + NFC_TXT), StandardCharsets.UTF_8)) {
        String line;
        while (null != (line = reader.readLine())) {
            Matcher matcher = ROUND_TRIP_MAPPING_LINE_PATTERN.matcher(line);
            if (matcher.matches()) {
                final String leftHandSide = matcher.group(1);
                final String rightHandSide = matcher.group(2).trim();
                List<String> diacritics = new ArrayList<>();
                for (String outputCodePoint : rightHandSide.split("\\s+")) {
                    int ch = Integer.parseInt(outputCodePoint, 16);
                    if (UCharacter.hasBinaryProperty(ch, UProperty.DIACRITIC)
                            // gennorm2 fails if U+0653-U+0656 are included in round-trip mappings
                            || (ch >= 0x653 && ch <= 0x656)) {
                        diacritics.add(outputCodePoint);
                    }
                }
                if (!diacritics.isEmpty()) {
                    StringBuilder replacementLine = new StringBuilder();
                    replacementLine.append(leftHandSide).append(">").append(rightHandSide);
                    replacementLine.append("  # one-way: diacritic");
                    if (diacritics.size() > 1) {
                        replacementLine.append("s");
                    }
                    for (String diacritic : diacritics) {
                        replacementLine.append(" ").append(diacritic);
                    }
                    line = replacementLine.toString();
                }
            }
            writer.write(line);
            writer.write("\n");
        }
    }
    logger.info("done.");
}
 
开发者ID:jprante,项目名称:elasticsearch-plugin-bundle,代码行数:50,代码来源:UTR30DataFileGenerator.java

示例4: has

import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
public boolean has(int codePoint) {
    return UCharacter.hasBinaryProperty(codePoint, propertyId);
}
 
开发者ID:anba,项目名称:es6draft,代码行数:4,代码来源:UnicodeData.java

示例5: isIdentifierStart

import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
 * <strong>[11.6] Names and Keywords</strong>
 * 
 * <pre>
 * IdentifierStart ::
 *     UnicodeIDStart
 *     $
 *     _
 *     \ UnicodeEscapeSequence
 * UnicodeIDStart ::
 *     any Unicode character with the Unicode property "ID_Start".
 * </pre>
 * 
 * @param c
 *            the character
 * @return {@code true} if the character is an identifier start character
 */
public static boolean isIdentifierStart(int c) {
    if (c <= 127) {
        return ('a' <= (c | 0x20) && (c | 0x20) <= 'z') || c == '$' || c == '_';
    }
    return UCharacter.hasBinaryProperty(c, UProperty.ID_START);
}
 
开发者ID:anba,项目名称:es6draft,代码行数:24,代码来源:Characters.java

示例6: isIdentifierPart

import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
 * <strong>[11.6] Names and Keywords</strong>
 * 
 * <pre>
 * IdentifierPart ::
 *     UnicodeIDContinue
 *     $
 *     _
 *     \ UnicodeEscapeSequence
 *     &lt;ZWNJ&gt;
 *     &lt;ZWJ&gt;
 * UnicodeIDContinue ::
 *     any Unicode character with the Unicode property "ID_Continue"
 * </pre>
 * 
 * @param c
 *            the character
 * @return {@code true} if the character is an identifier part character
 */
public static boolean isIdentifierPart(int c) {
    if (c <= 127) {
        return ('a' <= (c | 0x20) && (c | 0x20) <= 'z') || ('0' <= c && c <= '9') || c == '$' || c == '_';
    }
    if (c == '\u200C' || c == '\u200D') {
        return true;
    }
    return UCharacter.hasBinaryProperty(c, UProperty.ID_CONTINUE);
}
 
开发者ID:anba,项目名称:es6draft,代码行数:29,代码来源:Characters.java

示例7: isUnicodeIDStart

import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
 * <strong>[11.6] Names and Keywords</strong>
 * 
 * <pre>
 * UnicodeIDStart ::
 *     any Unicode character with the Unicode property "ID_Start".
 * </pre>
 * 
 * @param c
 *            the character
 * @return {@code true} if the character is an identifier start character
 */
public static boolean isUnicodeIDStart(int c) {
    if (c <= 127) {
        return ('a' <= (c | 0x20) && (c | 0x20) <= 'z');
    }
    return UCharacter.hasBinaryProperty(c, UProperty.ID_START);
}
 
开发者ID:anba,项目名称:es6draft,代码行数:19,代码来源:Characters.java

示例8: isUnicodeIDContinue

import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
 * <strong>[11.6] Names and Keywords</strong>
 * 
 * <pre>
 * UnicodeIDContinue ::
 *     any Unicode character with the Unicode property "ID_Continue"
 * </pre>
 * 
 * @param c
 *            the character
 * @return {@code true} if the character is an identifier part character
 */
public static boolean isUnicodeIDContinue(int c) {
    if (c <= 127) {
        return ('a' <= (c | 0x20) && (c | 0x20) <= 'z') || ('0' <= c && c <= '9') || c == '_';
    }
    return UCharacter.hasBinaryProperty(c, UProperty.ID_CONTINUE);
}
 
开发者ID:anba,项目名称:es6draft,代码行数:19,代码来源:Characters.java


注:本文中的com.ibm.icu.lang.UCharacter.hasBinaryProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。