FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
unidecode/perl2python.pl at master · NorthIsUp/unidecode · GitHub
NorthIsUp
unidecode
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
unidecode
/
perl2python.pl
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (35 loc) · 897 Bytes
Breadcrumbs
unidecode
/
perl2python.pl
Copy path
File metadata and controls
50 lines (35 loc) · 897 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
usage:
#
#
perl perl2python.pl --input=Text-Unidecode-1.00_01/lib/Text/Unidecode --output unidecode
use
Getopt::Long;
my
$input
=
"
.
"
;
my
$output
=
"
.
"
;
$result
= GetOptions(
"
input=s
"
=>
\
$input
,
"
output=s
"
=>
\
$output
);
sub
python_escape
{
my
$x
=
shift
;
return
'
'
unless
defined
(
$x
);
$x
=~
s
/
\\
/
\\\\
/
gs
;
$x
=~
s
/
'
/
\\
'
/
gs
;
$x
=~
s
/
([
\x00
-
\x1f
])
/
sprintf("
\\
x%02x", ord(
$1
))
/
ges
;
return
$x
;
}
#
print "$input\n";
push
(
@INC
,
$input
);
mkdir
$output
;
my
$n
;
for
(
$n
= 0;
$n
< 256;
$n
++) {
eval
(
sprintf
(
"
require x%02x;
\n
"
,
$n
) );
next
unless
(
$#
{
$Text::Unidecode::Char
[
$n
]} >= 0 );
#
print "$n\n";
open
(PYTHON,
sprintf
(
"
>
%s
/x%03x.py
"
,
$output
,
$n
));
print
PYTHON
"
data = (
\n
"
;
my
$m
= 0;
for
my
$t
(@{
$Text::Unidecode::Char
[
$n
]}) {
print
PYTHON
"
'
"
, &python_escape(
$t
),
"
', #
"
;
printf
PYTHON
"
0x%02x
\n
"
,
$m
;
$m
++;
}
print
PYTHON
"
)
\n
"
;
close
(PYTHON)
}
Back
|
FazBrowse Home
|
New Git URL