在哪里可以找到PHP音译器(Intl)的ID或规则列表? [英] Where can I find a list of IDs or rules for the PHP transliterator (Intl)?
问题描述
Transliterator::listIDs()
将列出ID,但显然不是完整列表.
Transliterator::listIDs()
will list IDs, but apparently it's not a complete list.
在此页面上的示例中,该ID如下:>
In the example from this page, the ID looks like:
Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();
有点奇怪,因为ID应该是唯一的.这看起来更像一条规则,但是如果我将其传递给createFromRules
方法:)
which is kind of weird, because IDs are supposed to be unique. This looks more like a rule, but it doesn't work if I pass it to the createFromRules
method :)
无论如何,我正在尝试从字符串中删除除破折号(-
)或特定列表中的字符之外的所有标点符号.
Anyway, I'm trying to remove any punctuation from the string, except dash (-
), or characters from a specific list.
您知道是否可行?还是有一些文档可以更好地解释音译器的语法?
Do you know if that's possible? Or is there some documentation that better explains the syntax for the transliterator ?
推荐答案
您还可以使用 Transliterator::createFromRules()
创建自己的规则
You can also create your own rules with Transliterator::createFromRules()
.
您可以查看预定义的规则:
You can take a look at the prefefined rules:
<?php
$a = new ResourceBundle(NULL, sprintf('icudt%dl-translit', INTL_ICU_VERSION), true);
foreach ($a['RuleBasedTransliteratorIDs'] as $name => $v) {
$file = @$v['file'];
if (!$file) {
$file = $v['internal'];
echo $name, " (direction $file[direction]; internal)\n";
} else {
echo $name, " (direction: $file[direction])\n";
echo $file['resource'];
}
echo "\n--------------\n";
}
格式化后,结果类似于此.
After formatting, the result looks like this.
这篇关于在哪里可以找到PHP音译器(Intl)的ID或规则列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!