简体   繁体   English

android中电话号码的特殊字符

[英]The special character of telephone number in android

It has a bug when I test contacts. 我测试联系人时有一个错误。 The bug address is PhoneNumberUtils.charToBCD() 错误地址为PhoneNumberUtils.charToBCD()

The error is java.lang.RuntimeException: invalid char for BCD; 错误为java.lang.RuntimeException:BCD的字符无效; that is to say the ; 也就是说; is not handled. 不处理。

What is the meaning of the special character of telephone number? 电话号码特殊字符是什么意思?

Thankful to any idea regarding this. 感谢对此的任何想法。

@SreekeshOkky mentioned "vcard" in his answer, so maybe it is trying to parse a phone number from a vCard. @SreekeshOkky在他的答案中提到了“ vcard”,所以也许它正试图从vCard解析电话号码。

In a vCard, phone numbers are usually encoded as free-form text, which means they can contain any character. 在vCard中,电话号码通常被编码为自由格式的文本,这意味着它们可以包含任何字符。

They can also be encoded as URIs. 它们也可以编码为URI。 A phone number URI will contain a semi-colon if the telephone number has an extension. 如果电话号码带有扩展名,则电话号码URI将包含分号。 For example: 例如:

tel:+1-555-555-5555;ext=5555

The exception is thrown due to 由于以下原因引发了异常

 private static int
    charToBCD(char c) {
        if (c >= '0' && c <= '9') {
            return c - '0';
        } else if (c == '*') {
            return 0xa;
        } else if (c == '#') {
            return 0xb;
        } else if (c == PAUSE) {
            return 0xc;
        } else if (c == WILD) {
            return 0xd;
        } else {
            throw new RuntimeException ("invalid char for BCD " + c);
        }
    }

in the PhoneNumberUtils.java - android-vcard So check a ; PhoneNumberUtils.java - android-vcard所以检查一个; is passed in your function 在您的函数中传递

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM