-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathchar.rkt
More file actions
129 lines (102 loc) · 3.29 KB
/
char.rkt
File metadata and controls
129 lines (102 loc) · 3.29 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#lang racket/base
(require "../test-utils.rkt")
(define v #\u5c)
(displayln v)
(displayln (char? #\a))
(displayln (char? 1))
(displayln (char? '(#\a)))
(displayln (char? "x"))
(displayln (char<? #\a #\b))
(displayln (char<? #\a #\a))
(displayln (char<? #\b #\a))
; This will produce the wrong result in JavaScript if the implementation
; compares characters directly instead of looking at their codepoints.
(displayln (char<? #\st #\𝌆))
(displayln (char<=? #\a #\a))
(displayln (char<=? #\a #\b))
(displayln (char<=? #\b #\a))
(displayln (char>? #\a #\a))
(displayln (char>? #\a #\b))
(displayln (char>? #\b #\a))
(displayln (char>=? #\a #\a))
(displayln (char>=? #\a #\b))
(displayln (char>=? #\b #\a))
(displayln (char=? #\a #\a))
(displayln (char=? #\b #\a))
(displayln (char=? #\u10 #\newline))
(displayln (char->integer #\a))
(displayln (char->integer #\☺))
(displayln (integer->char 127874))
(displayln (char-utf-8-length #\a))
(displayln (char-utf-8-length #\🎂))
(println #\a)
(println #\tab)
(println #\߆)
(println #\🎂)
(println (char-upcase #\a))
(println (char-upcase #\ß))
(println (char-upcase #\fi)) ; upper case is longer than 1 character (FI).
(println (char-downcase #\A))
(println (char-downcase #\ẞ))
;; Not implemented:
; (println (char-titlecase #\a))
; (println (char-foldcase #\A))
; (println (char-foldcase #\ß))
; (println (char-foldcase #\ß))
(displayln "char-alphabetic-case?")
(println (char-alphabetic? #\A))
(println (char-alphabetic? #\Я))
(println (char-alphabetic? #\tab))
(displayln "char-lower-case?")
(println (char-lower-case? #\A))
(println (char-lower-case? #\a))
(println (char-lower-case? #\Я))
(println (char-lower-case? #\я))
(println (char-lower-case? #\5))
(displayln "char-upper-case?")
(println (char-upper-case? #\A))
(println (char-upper-case? #\a))
(println (char-upper-case? #\Я))
(println (char-upper-case? #\Я))
(println (char-upper-case? #\5))
(displayln "char-title-case?")
(println (char-title-case? #\A))
(println (char-title-case? #\a))
(println (char-title-case? #\Я))
(println (char-title-case? #\Я))
(println (char-title-case? #\5))
(displayln "char-numeric?")
(println (char-numeric? #\5)) ; Nd
(run-if-version "7.0.0.1"
(println (char-numeric? #\Ⅻ)) ; Nl
(println (char-numeric? #\㊲))) ; No
;; TODO: the following should return #t but returns #f
;; see comments in runtime/core/char.js
;; and https://github.com/vishesh/racketscript/issues/176
;; (println (char-numeric? #\六)) ; Lo
(displayln "char-symbolic?")
(println (char-symbolic? #\A))
(println (char-symbolic? #\∄))
(displayln "char-punctuation?")
(println (char-punctuation? #\A))
(println (char-punctuation? #\;))
(displayln "char-graphic?")
(println (char-graphic? #\A))
(println (char-graphic? #\🎂))
(println (char-graphic? #\㊲))
(println (char-graphic? #\tab))
(displayln "char-whitespace?")
(println (char-whitespace? #\A))
(println (char-whitespace? #\space))
(println (char-whitespace? #\newline))
(println (char-whitespace? #\tab))
(displayln "char-blank?")
(println (char-blank? #\A))
(println (char-blank? #\space))
(println (char-blank? #\newline))
(println (char-blank? #\tab))
(displayln "char-iso-control?")
(println (char-iso-control? #\A))
(println (char-iso-control? #\nul))
(println (char-iso-control? #\rubout))
(println (char-iso-control? #\u9F))