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
4dcd9522
Commit
4dcd9522
authored
Oct 27, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FromLocale and ToLocale based on FromCharset and ToCharset
parent
b79da009
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
71 deletions
+4
-71
src/text/unicode.c
src/text/unicode.c
+4
-71
No files found.
src/text/unicode.c
View file @
4dcd9522
...
...
@@ -43,73 +43,6 @@
#include <errno.h>
#include <wctype.h>
#if defined (ASSUME_UTF8)
/* Cool */
#elif defined (WIN32) || defined (UNDER_CE)
# define USE_MB2MB 1
# include <io.h>
static
char
*
locale_dup
(
const
char
*
string
,
bool
from
)
{
char
*
out
;
int
len
;
len
=
1
+
MultiByteToWideChar
(
from
?
CP_ACP
:
CP_UTF8
,
0
,
string
,
-
1
,
NULL
,
0
);
wchar_t
*
wide
=
malloc
(
len
*
sizeof
(
wchar_t
));
if
(
wide
==
NULL
)
return
NULL
;
MultiByteToWideChar
(
from
?
CP_ACP
:
CP_UTF8
,
0
,
string
,
-
1
,
wide
,
len
);
len
=
1
+
WideCharToMultiByte
(
from
?
CP_UTF8
:
CP_ACP
,
0
,
wide
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
out
=
malloc
(
len
);
if
(
out
!=
NULL
)
WideCharToMultiByte
(
from
?
CP_UTF8
:
CP_ACP
,
0
,
wide
,
-
1
,
out
,
len
,
NULL
,
NULL
);
free
(
wide
);
return
out
;
}
#elif defined (HAVE_ICONV)
# define USE_ICONV 1
static
char
*
locale_dup
(
const
char
*
string
,
bool
from
)
{
vlc_iconv_t
hd
=
vlc_iconv_open
(
from
?
"UTF-8"
:
""
,
from
?
""
:
"UTF-8"
);
if
(
hd
==
(
vlc_iconv_t
)(
-
1
))
return
NULL
;
/* Uho! */
const
char
*
iptr
=
string
;
size_t
inb
=
strlen
(
string
);
size_t
outb
=
inb
*
6
+
1
;
char
output
[
outb
],
*
optr
=
output
;
while
(
vlc_iconv
(
hd
,
&
iptr
,
&
inb
,
&
optr
,
&
outb
)
==
(
size_t
)(
-
1
))
{
*
optr
++
=
'?'
;
outb
--
;
iptr
++
;
inb
--
;
vlc_iconv
(
hd
,
NULL
,
NULL
,
NULL
,
NULL
);
/* reset */
}
*
optr
=
'\0'
;
vlc_iconv_close
(
hd
);
assert
(
inb
==
0
);
assert
(
*
iptr
==
'\0'
);
assert
(
*
optr
==
'\0'
);
assert
(
strlen
(
output
)
==
(
size_t
)(
optr
-
output
));
return
strdup
(
output
);
}
#else
# error No UTF8 charset conversion implemented on this platform!
#endif
/**
* Releases (if needed) a localized or uniformized string.
* @param str non-NULL return value from FromLocale() or ToLocale().
...
...
@@ -138,7 +71,7 @@ char *FromLocale (const char *locale)
#ifdef ASSUME_UTF8
return
(
char
*
)
locale
;
#else
return
locale
?
locale_dup
(
locale
,
tru
e
)
:
NULL
;
return
locale
?
FromCharset
(
""
,
local
e
)
:
NULL
;
#endif
}
...
...
@@ -156,7 +89,7 @@ char *FromLocaleDup (const char *locale)
#ifdef ASSUME_UTF8
return
strdup
(
locale
);
#else
return
locale_dup
(
locale
,
tru
e
);
return
FromCharset
(
""
,
local
e
);
#endif
}
...
...
@@ -175,7 +108,7 @@ char *ToLocale (const char *utf8)
#ifdef ASSUME_UTF8
return
(
char
*
)
utf8
;
#else
return
utf8
?
locale_dup
(
utf8
,
false
)
:
NULL
;
return
utf8
?
ToCharset
(
""
,
utf8
)
:
NULL
;
#endif
}
...
...
@@ -194,7 +127,7 @@ char *ToLocaleDup (const char *utf8)
#ifdef ASSUME_UTF8
return
strdup
(
utf8
);
#else
return
locale_dup
(
utf8
,
false
);
return
ToCharset
(
""
,
utf8
);
#endif
}
...
...
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