summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorKaushal Modi <kaushal.modi@gmail.com>2018-06-06 17:44:11 -0400
committerKaushal Modi <kaushal.modi@gmail.com>2018-06-08 15:14:29 -0400
commit24df909d8a953f2b7ba0e0d1adf3a256042cd9bc (patch)
tree8ee5c50bf6084fa1c60a3c29f8601946230666d2 /compiler
parent3e799d7876110d970c365d61c05e887729488e2f (diff)
downloadNim-24df909d8a953f2b7ba0e0d1adf3a256042cd9bc.tar.gz
Make isUpper (and variants) work for strings with non-alpha chars
The other variants are isLower, isUpperAscii and isLowerAscii

Fixes https://github.com/nim-lang/Nim/issues/7963.

This commit changes the behavior and signatures of:

- isUpper, isLower in the unicode module
- isUpperAscii, isLowerAscii in the strutils module

A second mandatory parameter skipNonAlpha is added to these 4 procs.

(This change affects only for the case where the input is a *string*.)

---

With skipNonAlpha set to true, the behavior mimics the Python isupper and
islower behavior i.e. non-alphabetic chars/runes are ignored when checking if
the string is upper-case or lower-case.

    Before this commit:

      doAssert(not isUpper("A B"))

    After this commit:

      doAssert(not isUpper("A B", false))    <-- old behavior
      doAssert isUpper("A B", true)

      Below two are equivalent:

                           isUpper("A B", true)

        isAlpha("A B") and isUpper("A B", false)

.. and the similar for other 3 procs.
Diffstat (limited to 'compiler')
0 files changed, 0 insertions, 0 deletions