repo.or.cz
/
xlua.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
try to get term working
[xlua.git]
/
utf8.lua
blob
6a54c3b6f21b06bc2f2c5387e15cd676bef90be5
1
function
to_unicode
(
utf8
)
2
local
utab
= {}
3
local
l
= #
utf8
4
local
i
=
1
5
while
i
<=
l
do
6
local
b
=
utf8
:
byte
(
i
)
7
i
=
$
+
1
8
if
b
&
0x80
==
0
then
9
table
.
insert
(
utab
,
b
)
10
continue
11
elseif
b
&
0xe0
==
0xc0
then
12
b
=
$
&
31
13
cont
=
1
14
elseif
b
&
0xf0
==
0xe0
then
15
b
=
$
&
15
16
cont
=
2
17
elseif
b
&
0xfc
==
0xf8
then
18
b
=
$
&
7
19
count
=
3
20
elseif
b
&
0xf7
==
0xf0
then
21
b
=
$
&
3
22
cont
=
4
23
elseif
b
&
0xfe
==
0xfd
then
24
b
=
$
&
1
25
cont
=
5
26
end
27
while
cont
>
0
do
28
b
= (
$
<<
6
)
|
(
utf8
:
byte
(
i
) &
0x3f
)
29
i
=
$
+
1
30
cont
=
$
-
1
31
end
32
table
.
insert
(
utab
,
b
)
33
end
34
return
utab
35
end
36