mirror of
https://github.com/irmen/prog8.git
synced 2025-01-11 13:29:45 +00:00
added string.lowerchar() and string.upperchar()
This commit is contained in:
parent
1d65d63bd9
commit
387a4b7c35
@ -224,6 +224,29 @@ _done rts
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub lowerchar(ubyte char @A) -> ubyte @A {
|
||||
%asm {{
|
||||
and #$7f
|
||||
cmp #97
|
||||
bcc +
|
||||
cmp #123
|
||||
bcs +
|
||||
and #%11011111
|
||||
+ rts
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub upperchar(ubyte char @A) -> ubyte @A {
|
||||
%asm {{
|
||||
cmp #65
|
||||
bcc +
|
||||
cmp #91
|
||||
bcs +
|
||||
ora #%00100000
|
||||
+ rts
|
||||
}}
|
||||
}
|
||||
|
||||
sub startswith(str st, str prefix) -> bool {
|
||||
ubyte prefix_len = length(prefix)
|
||||
ubyte str_len = length(st)
|
||||
|
@ -114,6 +114,18 @@ string {
|
||||
}
|
||||
}
|
||||
|
||||
sub lowerchar(ubyte char) -> ubyte {
|
||||
if char >= 'A' and char <= 'Z'
|
||||
char |= %00100000
|
||||
return char
|
||||
}
|
||||
|
||||
sub upperchar(ubyte char) -> ubyte {
|
||||
if char >= 'a' and char <= 'z'
|
||||
char &= %11011111
|
||||
return char
|
||||
}
|
||||
|
||||
sub startswith(str st, str prefix) -> bool {
|
||||
ubyte prefix_len = length(prefix)
|
||||
ubyte str_len = length(st)
|
||||
|
@ -191,6 +191,12 @@ Provides string manipulation routines.
|
||||
``upper(string)``
|
||||
Uppercases the petscii-string in place.
|
||||
|
||||
``lowerchar(char)``
|
||||
Returns lowercased character.
|
||||
|
||||
``upperchar(char)``
|
||||
Returns uppercased character.
|
||||
|
||||
``startswith(string, prefix) -> bool``
|
||||
Returns true if string starts with prefix, otherwise false
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user