Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
f9e4f398
Commit
f9e4f398
authored
Aug 31, 2009
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IsSpace
R=rsc DELTA=39 (39 added, 0 deleted, 0 changed) OCL=34153 CL=34167
parent
fe8ff955
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
+39
-0
src/pkg/unicode/letter.go
src/pkg/unicode/letter.go
+12
-0
src/pkg/unicode/letter_test.go
src/pkg/unicode/letter_test.go
+27
-0
No files found.
src/pkg/unicode/letter.go
View file @
f9e4f398
...
...
@@ -117,6 +117,18 @@ func IsLetter(rune int) bool {
return
Is
(
Letter
,
rune
);
}
// IsSpace reports whether the rune is a white space character.
func
IsSpace
(
rune
int
)
bool
{
if
rune
<=
0xFF
{
// quick Latin-1 check
switch
rune
{
case
'\t'
,
'\n'
,
'\v'
,
'\f'
,
'\r'
,
' '
,
0x85
,
0xA0
:
return
true
;
}
return
false
;
}
return
Is
(
White_Space
,
rune
);
}
// To maps the rune to the specified case: UpperCase, LowerCase, or TitleCase
func
To
(
_case
int
,
rune
int
)
int
{
if
_case
<
0
||
MaxCase
<=
_case
{
...
...
src/pkg/unicode/letter_test.go
View file @
f9e4f398
...
...
@@ -92,6 +92,20 @@ var notletterTest = []int{
0x10ffff
,
}
// Contains all the special cased Latin-1 chars.
var
spaceTest
=
[]
int
{
0x09
,
0x0a
,
0x0b
,
0x0c
,
0x0d
,
0x20
,
0x85
,
0xA0
,
0x2000
,
0x3000
,
}
type
caseT
struct
{
cas
,
in
,
out
int
}
...
...
@@ -291,3 +305,16 @@ func TestToTitleCase(t *testing.T) {
}
}
}
func
TestIsSpace
(
t
*
testing
.
T
)
{
for
_
,
c
:=
range
spaceTest
{
if
!
IsSpace
(
c
)
{
t
.
Errorf
(
"IsSpace(U+%04X) = false; want true"
,
c
);
}
}
for
_
,
c
:=
range
letterTest
{
if
IsSpace
(
c
)
{
t
.
Errorf
(
"IsSpace(U+%04X) = true; want false"
,
c
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment