-
Notifications
You must be signed in to change notification settings - Fork 3
/
char.type.spin2
66 lines (55 loc) · 1.74 KB
/
char.type.spin2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{
--------------------------------------------
Filename: char.type.spin2
Author: Jesse Burt
Description: Character processing and formatting routines (P2 version)
Copyright (c) 2022
Started Dec 14, 2019
Updated Oct 9, 2022
See end of file for terms of use.
--------------------------------------------
}
#ifndef TERMCODES_H
#include "termcodes.spin2h"
#endif
PUB isalpha(ch): flag
' Test if character is alphabetic
' Returns: TRUE if alphabetic, FALSE otherwise
return (lookdown(ch: "A".."Z", "a".."z") <> 0)
PUB isalphanumeric(ch): flag
' Test if character is alphanumeric
' Returns: TRUE if alphanumeric, FALSE otherwise
return (lookdown(ch: "0".."9", "A".."Z", "a".."z") <> 0)
PUB isdigit(ch): flag
' Test if character is a digit
' Returns: TRUE if ch is a digit, FALSE otherwise
return (lookdown(ch: "0".."9") <> 0)
PUB islower(ch): flag
' Test if character is lowercase
' Returns: TRUE if lowercase, FALSE otherwise
return (lookdown(ch: "a".."z") <> 0)
PUB isspace(ch): flag
' Test if character is a space (0x20), tab (\t) or newline (\n)
' ch: Character to be tested
' Returns: TRUE if ch is a space, tab or line-feed
return (lookdown(ch: " ", TB, LF) <> 0)
PUB isupper(ch): flag
' Test if character is uppercase
return (lookdown(ch: "A".."Z") <> 0)
PUB isxdigit(ch): flag
' Test if character is a hexadecimal digit
' ch: Character to be tested
' Returns: TRUE if ch is a hex digit
return (lookdown(ch: "0".."9", "A".."F", "a".."f") <> 0)
PUB tolower(ch): lc
' Convert character to lowercase
if isupper(ch)
return (ch + 32)
else
return ch
PUB toupper(ch): uc
' Convert character to uppercase
if islower(ch)
return (ch - 32)
else
return ch