Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
a6e6fbff
Commit
a6e6fbff
authored
Oct 27, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LUA: use FromCharset()
parent
4dcd9522
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
27 deletions
+14
-27
modules/misc/lua/libs/strings.c
modules/misc/lua/libs/strings.c
+8
-21
share/lua/README.txt
share/lua/README.txt
+2
-2
share/lua/playlist/katsomo.lua
share/lua/playlist/katsomo.lua
+3
-3
share/lua/playlist/lelombrik.lua
share/lua/playlist/lelombrik.lua
+1
-1
No files found.
modules/misc/lua/libs/strings.c
View file @
a6e6fbff
...
@@ -113,31 +113,18 @@ static int vlclua_convert_xml_special_chars( lua_State *L )
...
@@ -113,31 +113,18 @@ static int vlclua_convert_xml_special_chars( lua_State *L )
return
i_top
;
return
i_top
;
}
}
static
int
vlclua_
iconv
(
lua_State
*
L
)
static
int
vlclua_
from_charset
(
lua_State
*
L
)
{
{
int
i_ret
;
size_t
i_out_bytes
,
i_in_bytes
;
char
*
psz_output
,
*
psz_original
;
if
(
lua_gettop
(
L
)
<
3
)
return
vlclua_error
(
L
);
if
(
lua_gettop
(
L
)
<
3
)
return
vlclua_error
(
L
);
const
char
*
psz_input
=
luaL_checklstring
(
L
,
3
,
&
i_in_bytes
)
;
size_t
i_in_bytes
;
const
char
*
psz_input
=
luaL_checklstring
(
L
,
2
,
&
i_in_bytes
);
if
(
i_in_bytes
==
0
)
return
vlclua_error
(
L
);
if
(
i_in_bytes
==
0
)
return
vlclua_error
(
L
);
vlc_iconv_t
iconv_handle
=
vlc_iconv_open
(
luaL_checkstring
(
L
,
1
),
luaL_checkstring
(
L
,
2
)
);
if
(
iconv_handle
==
(
vlc_iconv_t
)
-
1
)
return
vlclua_error
(
L
);
i_out_bytes
=
4
*
i_in_bytes
;
psz_output
=
psz_original
=
malloc
(
i_out_bytes
+
1
);
i_ret
=
vlc_iconv
(
iconv_handle
,
&
psz_input
,
&
i_in_bytes
,
&
psz_output
,
&
i_out_bytes
);
*
psz_output
=
'\0'
;
lua_pushstring
(
L
,
psz_original
);
const
char
*
psz_charset
=
luaL_checkstring
(
L
,
1
);
vlc_iconv_close
(
iconv_handle
);
char
*
psz_output
=
FromCharset
(
psz_charset
,
psz_input
,
i_in_bytes
);
free
(
psz_original
);
lua_pushstring
(
L
,
psz_output
?
psz_output
:
""
);
free
(
psz_output
);
return
1
;
return
1
;
}
}
...
@@ -149,7 +136,7 @@ static const luaL_Reg vlclua_strings_reg[] = {
...
@@ -149,7 +136,7 @@ static const luaL_Reg vlclua_strings_reg[] = {
{
"encode_uri_component"
,
vlclua_encode_uri_component
},
{
"encode_uri_component"
,
vlclua_encode_uri_component
},
{
"resolve_xml_special_chars"
,
vlclua_resolve_xml_special_chars
},
{
"resolve_xml_special_chars"
,
vlclua_resolve_xml_special_chars
},
{
"convert_xml_special_chars"
,
vlclua_convert_xml_special_chars
},
{
"convert_xml_special_chars"
,
vlclua_convert_xml_special_chars
},
{
"
iconv"
,
vlclua_iconv
},
{
"
from_charset"
,
vlclua_from_charset
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
...
...
share/lua/README.txt
View file @
a6e6fbff
...
@@ -378,8 +378,8 @@ strings.resolve_xml_special_chars( [str1, [str2, [...]]] ): Resolve XML
...
@@ -378,8 +378,8 @@ strings.resolve_xml_special_chars( [str1, [str2, [...]]] ): Resolve XML
variables as it had arguments.
variables as it had arguments.
strings.convert_xml_special_chars( [str1, [str2, [...]]] ): Do the inverse
strings.convert_xml_special_chars( [str1, [str2, [...]]] ): Do the inverse
operation.
operation.
strings.
iconv( str1 to, str2 from, str ): use vlc_iconv to convert string
strings.
from_charset( charset, str ): convert a string from a specified
from encoding to another
character encoding into UTF-8.
Variables
Variables
---------
---------
...
...
share/lua/playlist/katsomo.lua
View file @
a6e6fbff
...
@@ -51,7 +51,7 @@ function parse()
...
@@ -51,7 +51,7 @@ function parse()
if
string.match
(
line
,
"<title>"
)
if
string.match
(
line
,
"<title>"
)
then
then
title
=
vlc
.
strings
.
decode_uri
(
find
(
line
,
"<title>(.-)<"
)
)
title
=
vlc
.
strings
.
decode_uri
(
find
(
line
,
"<title>(.-)<"
)
)
title
=
vlc
.
strings
.
iconv
(
"UTF-8"
,
"ISO_8859-1"
,
title
)
title
=
vlc
.
strings
.
from_charset
(
"ISO_8859-1"
,
title
)
end
end
if
(
find
(
line
,
"img class=\"
pngImg
\
" src=\"
/
multimedia
/
template
/
logos
" ) )
if
(
find
(
line
,
"img class=\"
pngImg
\
" src=\"
/
multimedia
/
template
/
logos
" ) )
then
then
...
@@ -59,13 +59,13 @@ function parse()
...
@@ -59,13 +59,13 @@ function parse()
end
end
for treeid,name in string.gmatch( line, "
/
\?
treeId
=
(
%
d
+
)
\
">([^<]+)</a"
)
do
for treeid,name in string.gmatch( line, "
/
\?
treeId
=
(
%
d
+
)
\
">([^<]+)</a"
)
do
name
=
vlc
.
strings
.
resolve_xml_special_chars
(
name
)
name
=
vlc
.
strings
.
resolve_xml_special_chars
(
name
)
name
=
vlc
.
strings
.
iconv
(
"UTF-8"
,
"ISO_8859-1"
,
name
)
name
=
vlc
.
strings
.
from_charset
(
"ISO_8859-1"
,
name
)
path
=
"http://www.katsomo.fi/?treeId="
..
treeid
path
=
"http://www.katsomo.fi/?treeId="
..
treeid
table.insert
(
p
,
{
path
=
path
;
name
=
name
;
url
=
vlc
.
path
;
arturl
=
arturl
;
}
)
table.insert
(
p
,
{
path
=
path
;
name
=
name
;
url
=
vlc
.
path
;
arturl
=
arturl
;
}
)
end
end
for
programid
in
string.gmatch
(
line
,
"<li class=\"
program
.
*
\
" id=\"
program
(
%
d
+
)
\
" title=\"
.
+
\
""
)
do
for
programid
in
string.gmatch
(
line
,
"<li class=\"
program
.
*
\
" id=\"
program
(
%
d
+
)
\
" title=\"
.
+
\
""
)
do
description
=
vlc
.
strings
.
resolve_xml_special_chars
(
find
(
line
,
"title=\"
(.
+
)
\
""
)
)
description
=
vlc
.
strings
.
resolve_xml_special_chars
(
find
(
line
,
"title=\"
(.
+
)
\
""
)
)
description
=
vlc
.
strings
.
iconv
(
"UTF-8"
,
"ISO_8859-1"
,
description
)
description
=
vlc
.
strings
.
from_charset
(
"ISO_8859-1"
,
description
)
path
=
"http://www.katsomo.fi/metafile.asx?p="
..
programid
..
"&bw=800"
path
=
"http://www.katsomo.fi/metafile.asx?p="
..
programid
..
"&bw=800"
table.insert
(
p
,
{
path
=
path
;
name
=
description
;
url
=
vlc
.
path
;
arturl
=
arturl
;
}
)
table.insert
(
p
,
{
path
=
path
;
name
=
description
;
url
=
vlc
.
path
;
arturl
=
arturl
;
}
)
end
end
...
...
share/lua/playlist/lelombrik.lua
View file @
a6e6fbff
...
@@ -38,7 +38,7 @@ function parse()
...
@@ -38,7 +38,7 @@ function parse()
if
string.match
(
line
,
"id=\"
nom_fichier
\
">"
)
then
if
string.match
(
line
,
"id=\"
nom_fichier
\
">"
)
then
title
=
string.gsub
(
line
,
".*\"
nom_fichier
\
">([^<]*).*"
,
"%1"
)
title
=
string.gsub
(
line
,
".*\"
nom_fichier
\
">([^<]*).*"
,
"%1"
)
if
title
then
if
title
then
title
=
vlc
.
strings
.
iconv
(
"UTF8"
,
"ISO_8859-1"
,
title
)
title
=
vlc
.
strings
.
from_charset
(
"ISO_8859-1"
,
title
)
end
end
elseif
string.match
(
line
,
"'file'"
)
then
elseif
string.match
(
line
,
"'file'"
)
then
_
,
_
,
path
=
string.find
(
line
,
"'file', *'([^']*)"
)
_
,
_
,
path
=
string.find
(
line
,
"'file', *'([^']*)"
)
...
...
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