Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
4e89a259
Commit
4e89a259
authored
Nov 15, 2022
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrc: Add support for named locales.
parent
d08d6f51
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
0 deletions
+47
-0
po.c
tools/wrc/po.c
+0
-0
utils.c
tools/wrc/utils.c
+46
-0
utils.h
tools/wrc/utils.h
+1
-0
No files found.
tools/wrc/po.c
View file @
4e89a259
This diff is collapsed.
Click to expand it.
tools/wrc/utils.c
View file @
4e89a259
...
...
@@ -223,6 +223,14 @@ int get_language_codepage( language_t lang )
return
codepage
;
}
language_t
get_language_from_name
(
const
char
*
name
)
{
WCHAR
nameW
[
LOCALE_NAME_MAX_LENGTH
];
MultiByteToWideChar
(
1252
,
0
,
name
,
-
1
,
nameW
,
ARRAY_SIZE
(
nameW
)
);
return
LocaleNameToLCID
(
nameW
,
LOCALE_ALLOW_NEUTRAL_NAMES
);
}
#else
/* _WIN32 */
struct
nls_info
...
...
@@ -360,6 +368,35 @@ static void load_locale_nls(void)
error
(
"unable to load locale.nls
\n
"
);
}
static
int
compare_locale_names
(
const
char
*
n1
,
const
WCHAR
*
n2
)
{
for
(;;)
{
WCHAR
ch1
=
(
unsigned
char
)
*
n1
++
;
WCHAR
ch2
=
*
n2
++
;
if
(
ch1
>=
'a'
&&
ch1
<=
'z'
)
ch1
-=
'a'
-
'A'
;
if
(
ch2
>=
'a'
&&
ch2
<=
'z'
)
ch2
-=
'a'
-
'A'
;
if
(
!
ch1
||
ch1
!=
ch2
)
return
ch1
-
ch2
;
}
}
static
const
NLS_LOCALE_LCNAME_INDEX
*
find_lcname_entry
(
const
char
*
name
)
{
int
min
=
0
,
max
=
locale_table
->
nb_lcnames
-
1
;
if
(
!
name
)
return
NULL
;
while
(
min
<=
max
)
{
int
res
,
pos
=
(
min
+
max
)
/
2
;
const
WCHAR
*
str
=
locale_strings
+
lcnames_index
[
pos
].
name
;
res
=
compare_locale_names
(
name
,
str
+
1
);
if
(
res
<
0
)
max
=
pos
-
1
;
else
if
(
res
>
0
)
min
=
pos
+
1
;
else
return
&
lcnames_index
[
pos
];
}
return
NULL
;
}
static
const
NLS_LOCALE_LCID_INDEX
*
find_lcid_entry
(
LCID
lcid
)
{
int
min
=
0
,
max
=
locale_table
->
nb_lcids
-
1
;
...
...
@@ -391,6 +428,15 @@ int get_language_codepage( language_t lang )
return
get_locale_data
(
entry
->
idx
)
->
idefaultansicodepage
;
}
language_t
get_language_from_name
(
const
char
*
name
)
{
const
NLS_LOCALE_LCNAME_INDEX
*
entry
;
if
(
!
locale_table
)
load_locale_nls
();
if
(
!
(
entry
=
find_lcname_entry
(
name
)))
return
0
;
return
get_locale_data
(
entry
->
idx
)
->
unique_lcid
;
}
#endif
/* _WIN32 */
static
WCHAR
*
utf8_to_unicode
(
const
char
*
src
,
int
srclen
,
int
*
dstlen
)
...
...
tools/wrc/utils.h
View file @
4e89a259
...
...
@@ -39,6 +39,7 @@ char *convert_string_utf8( const string_t *str, int codepage );
void
free_string
(
string_t
*
str
);
int
check_valid_utf8
(
const
string_t
*
str
,
int
codepage
);
int
get_language_codepage
(
language_t
lang
);
language_t
get_language_from_name
(
const
char
*
name
);
int
is_valid_codepage
(
int
cp
);
#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