Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f2c47114
Commit
f2c47114
authored
Jan 01, 2003
by
Skip Montanaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search for Unicode character names using regular expressions.
parent
decc6a47
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
Demo/scripts/find-uname.py
Demo/scripts/find-uname.py
+40
-0
No files found.
Demo/scripts/find-uname.py
0 → 100644
View file @
f2c47114
#!/usr/bin/env python
"""
For each argument on the command line, look for it in the set of all Unicode
names. Arguments are treated as case-insensitive regular expressions, e.g.:
% find-uname 'small letter a$' 'horizontal line'
*** small letter a$ matches ***
LATIN SMALL LETTER A (97)
COMBINING LATIN SMALL LETTER A (867)
CYRILLIC SMALL LETTER A (1072)
PARENTHESIZED LATIN SMALL LETTER A (9372)
CIRCLED LATIN SMALL LETTER A (9424)
FULLWIDTH LATIN SMALL LETTER A (65345)
*** horizontal line matches ***
HORIZONTAL LINE EXTENSION (9135)
"""
import
unicodedata
import
sys
import
re
def
main
(
args
):
unicode_names
=
[]
for
ix
in
range
(
sys
.
maxunicode
+
1
):
try
:
unicode_names
.
append
(
(
ix
,
unicodedata
.
name
(
unichr
(
ix
)))
)
except
ValueError
:
# no name for the character
pass
for
arg
in
args
:
pat
=
re
.
compile
(
arg
,
re
.
I
)
matches
=
[(
x
,
y
)
for
(
x
,
y
)
in
unicode_names
if
pat
.
search
(
y
)
is
not
None
]
if
matches
:
print
"***"
,
arg
,
"matches"
,
"***"
for
(
x
,
y
)
in
matches
:
print
"%s (%d)"
%
(
y
,
x
)
if
__name__
==
"__main__"
:
main
(
sys
.
argv
[
1
:])
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