• <bdo id='azxVE'></bdo><ul id='azxVE'></ul>
  • <small id='azxVE'></small><noframes id='azxVE'>

    <legend id='azxVE'><style id='azxVE'><dir id='azxVE'><q id='azxVE'></q></dir></style></legend>

    1. <i id='azxVE'><tr id='azxVE'><dt id='azxVE'><q id='azxVE'><span id='azxVE'><b id='azxVE'><form id='azxVE'><ins id='azxVE'></ins><ul id='azxVE'></ul><sub id='azxVE'></sub></form><legend id='azxVE'></legend><bdo id='azxVE'><pre id='azxVE'><center id='azxVE'></center></pre></bdo></b><th id='azxVE'></th></span></q></dt></tr></i><div id='azxVE'><tfoot id='azxVE'></tfoot><dl id='azxVE'><fieldset id='azxVE'></fieldset></dl></div>
    2. <tfoot id='azxVE'></tfoot>

      1. 转换字符(铸造与 .getNumericValue)

        时间:2023-07-27

        <tfoot id='keuKy'></tfoot>
        <i id='keuKy'><tr id='keuKy'><dt id='keuKy'><q id='keuKy'><span id='keuKy'><b id='keuKy'><form id='keuKy'><ins id='keuKy'></ins><ul id='keuKy'></ul><sub id='keuKy'></sub></form><legend id='keuKy'></legend><bdo id='keuKy'><pre id='keuKy'><center id='keuKy'></center></pre></bdo></b><th id='keuKy'></th></span></q></dt></tr></i><div id='keuKy'><tfoot id='keuKy'></tfoot><dl id='keuKy'><fieldset id='keuKy'></fieldset></dl></div>
            <tbody id='keuKy'></tbody>

          1. <small id='keuKy'></small><noframes id='keuKy'>

              <bdo id='keuKy'></bdo><ul id='keuKy'></ul>
            • <legend id='keuKy'><style id='keuKy'><dir id='keuKy'><q id='keuKy'></q></dir></style></legend>
                  本文介绍了转换字符(铸造与 .getNumericValue)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  为什么强制转换(int)可以正确地将符号的字符转换为int,但是Character.getNumericValue('someSymbolCharValue');"不能吗?

                  Why is it that casting (int) can convert chars of a symbol to int properly, but "Character.getNumericValue('someSymbolCharValue');" can't?

                  例如"Character.getNumericValue('?');" 将返回 -1,即使 char 可以用 "(int) '?'" 表示为 int返回 63

                  E.g. "Character.getNumericValue('?');" will return -1 even though the char can be presented as int with "(int) '?'" where it will return 63

                  推荐答案

                  一个字符的数值"不是它的 ASCII/Unicode 索引值.Character.getNumericValue 方法 将尝试通过应用字符的数字含义将 char 转换为 int:

                  A character's "numeric value" is not its ASCII/Unicode index value. The Character.getNumericValue method will attempt to convert the char to an int by applying the character's numeric meaning:

                  返回指定的 Unicode 字符表示的 int 值.例如,字符 'u216C'(罗马数字 50)将返回一个值为 50 的 int.大写字母 AZ('u0041' 到 'u005A')、小写字母('u0061' 到 'u007A')和全角变体('uFF21' 到 'uFF3A' 和 'uFF41'通过 'uFF5A') 形式具有从 10 到 35 的数值.这与 Unicode 规范无关,Unicode 规范不会为这些 char 值分配数值.

                  Returns the int value that the specified Unicode character represents. For example, the character 'u216C' (the roman numeral fifty) will return an int with a value of 50. The letters A-Z in their uppercase ('u0041' through 'u005A'), lowercase ('u0061' through 'u007A'), and full width variant ('uFF21' through 'uFF3A' and 'uFF41' through 'uFF5A') forms have numeric values from 10 through 35. This is independent of the Unicode specification, which does not assign numeric values to these char values.

                  如果字符没有数值,则返回-1.如果字符具有不能表示为非负整数的数值(例如,小数值),则返回 -2.

                  If the character does not have a numeric value, then -1 is returned. If the character has a numeric value that cannot be represented as a nonnegative integer (for example, a fractional value), then -2 is returned.

                  预计 getNumericValue 不会同意将 char 强制转换为 int.

                  It is expected that getNumericValue will not agree with casting the char to an int.

                  这篇关于转换字符(铸造与 .getNumericValue)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Java:如何检查字符是否属于特定的 unicode 块? 下一篇:将一个字符与多个字符进行比较

                  相关文章

                  最新文章

                  <i id='k9CK2'><tr id='k9CK2'><dt id='k9CK2'><q id='k9CK2'><span id='k9CK2'><b id='k9CK2'><form id='k9CK2'><ins id='k9CK2'></ins><ul id='k9CK2'></ul><sub id='k9CK2'></sub></form><legend id='k9CK2'></legend><bdo id='k9CK2'><pre id='k9CK2'><center id='k9CK2'></center></pre></bdo></b><th id='k9CK2'></th></span></q></dt></tr></i><div id='k9CK2'><tfoot id='k9CK2'></tfoot><dl id='k9CK2'><fieldset id='k9CK2'></fieldset></dl></div>
                  • <bdo id='k9CK2'></bdo><ul id='k9CK2'></ul>
                1. <legend id='k9CK2'><style id='k9CK2'><dir id='k9CK2'><q id='k9CK2'></q></dir></style></legend>

                  <small id='k9CK2'></small><noframes id='k9CK2'>

                    <tfoot id='k9CK2'></tfoot>