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
04cfc6a3
Commit
04cfc6a3
authored
Mar 22, 2006
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up
parent
be639de2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
32 deletions
+28
-32
src/misc/unicode.c
src/misc/unicode.c
+28
-32
No files found.
src/misc/unicode.c
View file @
04cfc6a3
...
...
@@ -154,9 +154,15 @@ static char *MB2MB( const char *string, UINT fromCP, UINT toCP )
}
#endif
/**
***************************************************************************
/**
* FromLocale: converts a locale string to UTF-8
*****************************************************************************/
*
* @param locale nul-terminated string to be converted
*
* @return a nul-terminated UTF-8 string, or NULL in case of error.
* To avoid memory leak, you have to pass the result to LocaleFree()
* when it is no longer needed.
*/
char
*
FromLocale
(
const
char
*
locale
)
{
if
(
locale
==
NULL
)
...
...
@@ -166,21 +172,10 @@ char *FromLocale( const char *locale )
# ifdef USE_ICONV
if
(
from_locale
.
hd
!=
(
vlc_iconv_t
)(
-
1
)
)
{
char
*
iptr
=
(
char
*
)
locale
,
*
output
,
*
optr
;
size_t
inb
,
outb
;
/*
* We are not allowed to modify the locale pointer, even if we cast it
* to non-const.
*/
inb
=
strlen
(
locale
);
/* FIXME: I'm not sure about the value for the multiplication
* (for western people, multiplication by 3 (Latin9) is needed).
* While UTF-8 could reach 6 bytes, no existing code point exceeds
* 4 bytes. */
outb
=
inb
*
4
+
1
;
optr
=
output
=
malloc
(
outb
);
const
char
*
iptr
=
locale
;
size_t
inb
=
strlen
(
locale
);
size_t
outb
=
inb
*
6
+
1
;
char
output
[
outb
],
*
optr
=
output
;
vlc_mutex_lock
(
&
from_locale
.
lock
);
vlc_iconv
(
from_locale
.
hd
,
NULL
,
NULL
,
NULL
,
NULL
);
...
...
@@ -201,7 +196,7 @@ char *FromLocale( const char *locale )
assert
(
*
iptr
==
'\0'
);
assert
(
*
optr
==
'\0'
);
assert
(
strlen
(
output
)
==
(
size_t
)(
optr
-
output
));
return
realloc
(
output
,
optr
-
output
+
1
);
return
strdup
(
output
);
}
# endif
/* USE_ICONV */
return
(
char
*
)
locale
;
...
...
@@ -224,9 +219,15 @@ char *FromLocaleDup( const char *locale )
}
/*****************************************************************************
* ToLocale: converts an UTF-8 string to locale
*****************************************************************************/
/**
* ToLocale: converts a UTF-8 string to local system encoding.
*
* @param utf8 nul-terminated string to be converted
*
* @return a nul-terminated string, or NULL in case of error.
* To avoid memory leak, you have to pass the result to LocaleFree()
* when it is no longer needed.
*/
char
*
ToLocale
(
const
char
*
utf8
)
{
if
(
utf8
==
NULL
)
...
...
@@ -236,19 +237,14 @@ char *ToLocale( const char *utf8 )
# ifdef USE_ICONV
if
(
to_locale
.
hd
!=
(
vlc_iconv_t
)(
-
1
)
)
{
char
*
iptr
=
(
char
*
)
utf8
,
*
output
,
*
optr
;
size_t
inb
,
outb
;
/*
* We are not allowed to modify the locale pointer, even if we cast it
* to non-const.
*/
inb
=
strlen
(
utf8
);
const
char
*
iptr
=
utf8
;
size_t
inb
=
strlen
(
utf8
);
/* FIXME: I'm not sure about the value for the multiplication
* (for western people, multiplication is not needed) */
outb
=
inb
*
2
+
1
;
size_t
outb
=
inb
*
2
+
1
;
char
output
[
outb
],
*
optr
=
output
;
optr
=
output
=
malloc
(
outb
);
vlc_mutex_lock
(
&
to_locale
.
lock
);
vlc_iconv
(
to_locale
.
hd
,
NULL
,
NULL
,
NULL
,
NULL
);
...
...
@@ -268,7 +264,7 @@ char *ToLocale( const char *utf8 )
assert
(
*
iptr
==
'\0'
);
assert
(
*
optr
==
'\0'
);
assert
(
strlen
(
output
)
==
(
size_t
)(
optr
-
output
));
return
realloc
(
output
,
optr
-
output
+
1
);
return
strdup
(
output
);
}
# endif
/* USE_ICONV */
return
(
char
*
)
utf8
;
...
...
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