文字过滤本地化 [英] Text Filter localization

查看:139
本文介绍了文字过滤本地化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我通过以下方式创建一个文本过滤器

if i create a text filter in the following manner

class AlphaTextFilter extends TextFilter {

    public char convert(char c, int status) {
        if (!validate(c))
                return 0;
        return c;
    }

    public boolean validate(char c) {
        return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
    }
}

如果code是一个设备上除英语以外语言的一些运行将它的工作...?我怎样才能让一个本地化....?

will it work if the code is run on a device with some language other than english...? how can i make a localized....?

推荐答案

这取决于你的工作的定义。如果作品你的意思是只接受[A-ZA-Z],然后肯定的。

That depends on what your definition of "work" is. If by "work" you mean accepts only [a-zA-Z], then yes.

如果你的意思是它会遇见谁想到会用字母,音节或表意字符(或字母更常见的用法)国际用户的期望,那么没有。现在大多数平台都提供了一些机制来识别UNI code字符类,并根据UNI code字符类大多数较新的正则表达式引擎的支持配套。在你的情况,\\ p {}信似乎是最合适的字符类。

If you mean would it meet the expectations of international users who expect to be using alphabetic, syllabic or ideographic characters (or "letters" in more common usage), then no. Most platforms now offer some mechanism for identifying the unicode character class, and most newer regex engines support matching based on unicode character classes. In your case, \p{letter} would appear to be the most appropriate character class.

这篇关于文字过滤本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆