Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
4411d2ba
Commit
4411d2ba
authored
Oct 02, 2005
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move UTF32 conversion to more appropriate file
parent
48827db4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
68 deletions
+71
-68
src/misc/charset.c
src/misc/charset.c
+1
-68
src/misc/unicode.c
src/misc/unicode.c
+70
-0
No files found.
src/misc/charset.c
View file @
4411d2ba
...
...
@@ -5,8 +5,7 @@
* Copyright (C) 2003-2005 the VideoLAN team
* $Id$
*
* Authors: Derk-Jan Hartman <thedj at users.sf.net>
* Rémi Denis-Courmont <rem at videolan.org>
* Author: Derk-Jan Hartman <thedj at users.sf.net>
*
* vlc_current_charset() an adaption of mp_locale_charset():
*
...
...
@@ -375,69 +374,3 @@ char *__vlc_fix_readdir_charset( vlc_object_t *p_this, const char *psz_string )
return
strdup
(
psz_string
);
}
/**********************************************************************
* UTF32toUTF8: converts UTF-32 to UTF-8
*********************************************************************/
char
*
UTF32toUTF8
(
const
wchar_t
*
src
,
size_t
len
,
size_t
*
newlen
)
{
char
*
res
,
*
out
;
/* allocate memory */
out
=
res
=
(
char
*
)
malloc
(
6
*
len
);
if
(
res
==
NULL
)
return
NULL
;
while
(
len
>
0
)
{
uint32_t
uv
=
*
src
++
;
len
--
;
if
(
uv
<
0x80
)
{
*
out
++
=
uv
;
continue
;
}
else
if
(
uv
<
0x800
)
{
*
out
++
=
((
uv
>>
6
)
|
0xc0
);
*
out
++
=
((
uv
&
0x3f
)
|
0x80
);
continue
;
}
else
if
(
uv
<
0x10000
)
{
*
out
++
=
((
uv
>>
12
)
|
0xe0
);
*
out
++
=
(((
uv
>>
6
)
&
0x3f
)
|
0x80
);
*
out
++
=
((
uv
&
0x3f
)
|
0x80
);
continue
;
}
else
{
*
out
++
=
((
uv
>>
18
)
|
0xf0
);
*
out
++
=
(((
uv
>>
12
)
&
0x3f
)
|
0x80
);
*
out
++
=
(((
uv
>>
6
)
&
0x3f
)
|
0x80
);
*
out
++
=
((
uv
&
0x3f
)
|
0x80
);
continue
;
}
}
len
=
out
-
res
;
res
=
realloc
(
res
,
len
);
if
(
newlen
!=
NULL
)
*
newlen
=
len
;
return
res
;
}
char
*
FromUTF32
(
const
wchar_t
*
src
)
{
size_t
len
;
const
wchar_t
*
in
;
/* determine the size of the string */
for
(
len
=
1
,
in
=
src
;
GetWBE
(
in
);
len
++
)
in
++
;
return
UTF32toUTF8
(
src
,
len
,
NULL
);
}
src/misc/unicode.c
View file @
4411d2ba
...
...
@@ -174,3 +174,73 @@ char *EnsureUTF8( char *str )
return
str
;
}
/**********************************************************************
* UTF32toUTF8: converts an array from UTF-32 to UTF-8
*********************************************************************/
char
*
UTF32toUTF8
(
const
wchar_t
*
src
,
size_t
len
,
size_t
*
newlen
)
{
char
*
res
,
*
out
;
/* allocate memory */
out
=
res
=
(
char
*
)
malloc
(
6
*
len
);
if
(
res
==
NULL
)
return
NULL
;
while
(
len
>
0
)
{
uint32_t
uv
=
*
src
++
;
len
--
;
if
(
uv
<
0x80
)
{
*
out
++
=
uv
;
continue
;
}
else
if
(
uv
<
0x800
)
{
*
out
++
=
((
uv
>>
6
)
|
0xc0
);
*
out
++
=
((
uv
&
0x3f
)
|
0x80
);
continue
;
}
else
if
(
uv
<
0x10000
)
{
*
out
++
=
((
uv
>>
12
)
|
0xe0
);
*
out
++
=
(((
uv
>>
6
)
&
0x3f
)
|
0x80
);
*
out
++
=
((
uv
&
0x3f
)
|
0x80
);
continue
;
}
else
{
*
out
++
=
((
uv
>>
18
)
|
0xf0
);
*
out
++
=
(((
uv
>>
12
)
&
0x3f
)
|
0x80
);
*
out
++
=
(((
uv
>>
6
)
&
0x3f
)
|
0x80
);
*
out
++
=
((
uv
&
0x3f
)
|
0x80
);
continue
;
}
}
len
=
out
-
res
;
res
=
realloc
(
res
,
len
);
if
(
newlen
!=
NULL
)
*
newlen
=
len
;
return
res
;
}
/**********************************************************************
* FromUTF32: converts an UTF-32 string to UTF-8
**********************************************************************
* The result must be free()'d. NULL on error.
*********************************************************************/
char
*
FromUTF32
(
const
wchar_t
*
src
)
{
size_t
len
;
const
wchar_t
*
in
;
/* determine the size of the string */
for
(
len
=
1
,
in
=
src
;
GetWBE
(
in
);
len
++
)
in
++
;
return
UTF32toUTF8
(
src
,
len
,
NULL
);
}
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