Skip to content

Commit 0a41ca2

Browse files
committed
Use i32 comparision instead of char
1 parent 676528e commit 0a41ca2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/runtime/lpython_builtin.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -768,9 +768,10 @@ def _lpython_str_upper(x: str) -> str:
768768
def _lpython_str_isalpha(s: str) -> bool:
769769
char: str
770770
for char in s:
771-
if 'a' <= char and char <= 'z':
771+
char_ord: i32 = ord(char)
772+
if 65 <= char_ord and char_ord <= 90:
772773
continue
773-
if 'A' <= char and char <= 'Z':
774+
if 97 <= char_ord and char_ord <= 122:
774775
continue
775776
return False
776777
return True
@@ -781,13 +782,14 @@ def _lpython_str_title(s: str) -> str:
781782
capitalize_next: bool = True
782783
char: str
783784
for char in s:
784-
if char >= 'a' and char <= 'z':
785+
char_ord: i32 = ord(char)
786+
if char_ord >= 97 and char_ord <= 122:
785787
if capitalize_next:
786788
result += chr(ord(char) - ord('a') + ord('A'))
787789
capitalize_next = False
788790
else:
789791
result += char
790-
elif char >= 'A' and char <= 'Z':
792+
elif char_ord >= 65 and char_ord <= 90:
791793
if capitalize_next:
792794
result += char
793795
capitalize_next = False

0 commit comments

Comments
 (0)