Recent Changes - Search:

Oktatás

* Programozás 1
  + feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

Teaching

* Programming 1 (BI)
  ◇ exercises
  ◇ quick link

teaching assets


Félévek

* 2025/26/2
* archívum


Linkek

* kalendárium
   - munkaszüneti napok '20
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C++
* C#
* Clojure
* D lang.
* Java
* Nim
* Nim2
* Scala


[ edit | logout ]
[ sandbox | passwd ]

testing a character

In C, these functions are in ctype.h

In Nim, they are in std/strutils

Let's see some of them:

import std/strutils     # is...() functions


echo isDigit('9')       # true
# This checks 0-9 ASCII characters only.

echo isLowerAscii('m')       # true
echo isLowerAscii('G')       # false
# This checks ASCII characters only. Use `unicode` module for UTF-8 support.

echo isUpperAscii('m')       # false
echo isUpperAscii('G')       # true
# This checks ASCII characters only. Use `unicode` module for UTF-8 support.

echo isAlphaAscii('x')        # true
echo isAlphaAscii('.')        # false
# Is the char in the English alphabet? Can be lowercase or uppercase.
# This checks a-z, A-Z ASCII characters only.

echo isAlphaNumeric('h')      # true
echo isAlphaNumeric('H')      # true
echo isAlphaNumeric('5')      # true
# This checks a-z, A-Z, 0-9 ASCII characters only.

# func isEmptyOrWhitespace(s: string): bool {.....}
echo isEmptyOrWhitespace("")                # true
echo isEmptyOrWhitespace("  \t   \n   ")    # true
echo isEmptyOrWhitespace("  \t x  \n   ")   # false

echo isSpaceAscii(' ')      # true
echo isSpaceAscii('\t')     # true
echo isSpaceAscii('\n')     # true
# Is the char a whitespace character?

The name Ascii in a function's name indicates that it only works with ASCII characters (or ASCII texts).

For Unicode support, we need the std/unicode module. We'll see that too.

Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2026 April 08, 11:05