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
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C#
* D lang.
* Java
* Nim
* Nim2
  + exercises
* XC=BASIC
* old
  ◇C++, ◇Clojure, ◇Scala


[ edit | logout ]
[ sandbox | passwd ]

Converting a character/text to uppercase/lowercase

ASCII

strutils: proc toLowerAscii(c: char): char
strutils: proc toLowerAscii(s: string): string
(1) ASCII
print('a'.upper())  # A

print('A'.lower())  # a

print("adam".upper())  # ADAM

print("LASZLO".lower())  # laszlo
import std/strutils    # strip, split, join


echo 'a'.toUpperAscii()   # A

echo 'A'.toLowerAscii()   # a

echo "adam".toUpperAscii()   # ADAM

echo "LASZLO".toLowerAscii()   # laszlo

𝥶In Python, 'a' is equivalent to "a". When you write 'a' in Python, it's actually a 1-long string.

Unicode

If you have Unicode characters, then use the std/unicode module.

unicode: proc toLower(c: Rune): Rune
unicode: proc toLower(s: string): string
(2) Unicode
print('á'.upper())  # Á

print('É'.lower())  # é

print("ádám".upper())  # ÁDÁM

print("LÁSZLÓ".lower())  # lászló
import std/unicode    # Rune


echo "á".toUpper()   # Á

echo "É".toLower()   # é

echo "ádám".toUpper()   # ÁDÁM

echo "LÁSZLÓ".toLower()   # lászló

let
  c: Rune = "á".runeAt(0)
  d: Rune = "É".runeAt(0)

echo c.toUpper()   # Á

echo d.toLower()   # é

𝥶Python cheats a bit. In Python, there is no distinct char type. When you create a "char", it's actually a 1-long string.

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 11, 14:03