Skip to content

Commit

Permalink
fix: lower/upper/capitalize return PyStr now
Browse files Browse the repository at this point in the history
  • Loading branch information
litlighilit committed May 6, 2024
1 parent ef33a9c commit a2cf5b7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/pylib/pystring/strmeth.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ template casefold*(a: StringLike): string =
## Mimics Python str.casefold() -> str
unicode.toLower(a)

func lower*(a: StringLike): string = toLower $a
func upper*(a: StringLike): string = toUpper $a
func lower*(a: StringLike): PyStr = toLower $a
func upper*(a: StringLike): PyStr = toUpper $a

func capitalize*(a: StringLike): string =
func capitalize*(a: StringLike): PyStr =
## make the first character have upper case and the rest lower case.
##
## while Nim's `unicode.capitalize` only make the first character upper-case.
Expand All @@ -25,7 +25,7 @@ func capitalize*(a: StringLike): string =
rune: Rune
i = 0
fastRuneAt(s, i, rune, doInc = true)
result = $toUpper(rune) & toLower substr(s, i)
result = $toUpper(rune) + substr(s, i).lower()


template seWith(seWith){.dirty.} =
Expand Down

0 comments on commit a2cf5b7

Please sign in to comment.