- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 ICU 音译器对某些文本进行非常具体的转换,如 here 所述.
我的文本包含半角片假名字符和常规拉丁字符。我想将半角片假名转换为全角片假名,同时保持非片假名字符不变。
我想简单地应用标准的“半角-全角”ICU 转换和一个只选择片假名的过滤器,但这没有用——片假名过滤器不适用于 Halfwidth Katakana Voiced Sound Mark ,这让我很惊讶。我想弄清楚这是故意的还是错误。
有关示例,请参见下面的代码。我试过:
有什么想法吗?有什么地方可以检查 ICU [:Katakana:]
过滤器中实际包含哪些字符?
void transliterateWithRules(String original, String rules) {
Transliterator transliterator = Transliterator.createFromRules("mytest", rules, Transliterator.FORWARD);
String result = transliterator.transliterate(original);
System.out.println(String.format("Transliteration result: \"%s\", codepoints: %s", result, toCodepoints(result)));
}
void test() {
String input = "ギ a"; // Unicode Codepoints: \uff77 \uff9e \u20 \u61
transliterateWithRules(input, ":: Halfwidth-Fullwidth;");
// Result:
// "ギ a", codepoints: \u30ae \u3000 \uff41
// This makes everything fullwidth, including the space and the latin 'a'
transliterateWithRules(input, ":: [:Katakana:]; :: Halfwidth-Fullwidth;");
// Result:
// "ギ a", codepoints: \u30ad \uff9e \u20 \u61
// This makes the Katakana KI fullwidth, and skips the space and 'a' as intended, but it also
// skips the Halfwidth Katakana Voiced Sound Mark (U+FF9E), which I expected to be converted.
transliterateWithRules(input, ":: [:^Latin:] Halfwidth-Fullwidth;");
// Result:
// "ギ a", codepoints: \u30ae \u3000 \u61
// Skips the latin 'a' as intended, but makes the space Fullwidth, which I don't want
transliterateWithRules(input, ":: [[:^Latin:]&[^\\ ]]; :: Halfwidth-Fullwidth;");
// Result:
// "ギ a", codepoints: \u30ae \u20 \u61
// Exactly what I want, for this example - but relying on a list of exclusions is fragile, since I am only
// excluding what I currently know about.
}
最佳答案
您可以在[:Katakana:]
集合here 中看到一个字符列表,其中既不包含 U+FF9E
也不包含 U+FF9F
。
这是因为 [:Katakana:]
等同于 [:Script=Katakana:]
,它测试 "Script" property一个字符。 U+FF9E
和 U+FF9F
都被标记为在平假名 和 片假名文本中使用,因此它们的脚本属性是“Common”(而不是而不是像 キ
这样的东西,它完全是“片假名”)。有一个包含两个脚本的“脚本扩展”属性,但是 [:Katakana:]
不检查它。
您可以手动将它们添加到集合中 ([[:Katakana:]\uFF9E\uFF9F]
),或者创建一个包含脚本扩展的集合:
[\p{sc=Katakana}\p{scx=Katakana}]
(请注意,这也包含一些其他共享字符。)
关于java - ICU 音译片假名过滤器不适用于半角片假名浊音标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32524917/
有没有办法让音译在 Emacs 中工作,就像现在在 Gmail 中一样?我特别有兴趣让它在西里尔文中工作。 作为引用,Gmail 执行以下操作:我可以输入svoboda,它会输出свобода。这允许
ruby中非英文字符的音译最简单的方法是什么。即转换如: 翻译“Gévry” #=> "Gevry" 最佳答案 Ruby 有一个 Iconv其 stdlib 中的库以与通常的 iconv 命令非常相似
ruby 1.9.3 警告 iconv 弃用,但我使用 iconv 删除变音符号以从 Iconv.iconv('asccii//translit', 'utf-8', 'Těžiště') 返回 Te
在 Ruby on Rails 中,您可以轻松地将“任何”文本转换为适用于子域/路径名的格式。 1) "I am nobody." -> "i-am-nobody" 2) "Grünkohl is a
我想将西里尔文字符串音译成最接近的拉丁文等价物。例如。 “матрешка”=> “matreshka”,“водка”=> “伏特加”。所以理想情况下,我希望在 NSString 或其他已经了解字母
以下是将 Google Transliteration 代码集成到 ASP.Net Pages 中的示例代码(随处可用)。 但我的问题是,如何在将在运行时生成的文本框中启用音译?此脚本需要文本框的 I
我正在使用 Java Swing 开发一个音译项目。它可以访问互联网,但我无法设置它。我们该怎么做?我们需要下载 Google API 库还是只需要一个函数调用就可以了? 这里有一些有用的音译链接:
在我们的 RoR 项目中,我们使用 postgres unaccent 函数来检索我们模型名称属性之一的非重音版本。 name 属性可以包含来自各种语言的任何重音字符。然后我们将其保存为 unacce
如何在我的 Java 应用程序中使用 Google Transliteration API。 如果我给一个String(英语或阿拉伯语)作为输入,Google Transliterator API 应
我正在做一个基于泰米尔语的 Web 应用程序。在我的应用程序中,我使用动态字段来添加用户详细信息。那么,动态字段有多个 ID 如何做到这一点或如何使用基于类的 Google 音译? // Lo
我有一个字符串对象 “有多个字符甚至特殊字符” 我正在尝试使用 UTF8Encoding utf8 = new UTF8Encoding(); ASCIIEncoding ascii = new AS
我使用过“Google AJAX Transliteration API”,它对我来说很顺利。 http://code.google.com/apis/ajaxlanguage/documentati
我是一名优秀的程序员,十分优秀!