Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
04ad71ee
Commit
04ad71ee
authored
Apr 30, 2012
by
Piotr Caban
Committed by
Alexandre Julliard
Apr 30, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Added IdnToAscii implementation.
parent
60b25b7d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
151 additions
and
3 deletions
+151
-3
locale.c
dlls/kernel32/locale.c
+151
-3
No files found.
dlls/kernel32/locale.c
View file @
04ad71ee
...
...
@@ -3881,16 +3881,164 @@ BOOL WINAPI IsNormalizedString(NORM_FORM NormForm, LPCWSTR lpString, INT cwLengt
return
FALSE
;
}
enum
{
BASE
=
36
,
TMIN
=
1
,
TMAX
=
26
,
SKEW
=
38
,
DAMP
=
700
,
INIT_BIAS
=
72
,
INIT_N
=
128
};
static
inline
INT
adapt
(
INT
delta
,
INT
numpoints
,
BOOL
firsttime
)
{
INT
k
;
delta
/=
(
firsttime
?
DAMP
:
2
);
delta
+=
delta
/
numpoints
;
for
(
k
=
0
;
delta
>
((
BASE
-
TMIN
)
*
TMAX
)
/
2
;
k
+=
BASE
)
delta
/=
BASE
-
TMIN
;
return
k
+
((
BASE
-
TMIN
+
1
)
*
delta
)
/
(
delta
+
SKEW
);
}
/******************************************************************************
* IdnToAscii (KERNEL32.@)
* Implementation of Punycode based on RFC 3492.
*/
INT
WINAPI
IdnToAscii
(
DWORD
dwFlags
,
LPCWSTR
lpUnicodeCharStr
,
INT
cchUnicodeChar
,
LPWSTR
lpASCIICharStr
,
INT
cchASCIIChar
)
{
FIXME
(
"%x %p %d %p %d
\n
"
,
dwFlags
,
lpUnicodeCharStr
,
cchUnicodeChar
,
static
const
WCHAR
prefixW
[]
=
{
'x'
,
'n'
,
'-'
,
'-'
};
WCHAR
*
norm_str
;
INT
i
,
label_start
,
label_end
,
norm_len
,
out_label
,
out
=
0
;
TRACE
(
"%x %p %d %p %d
\n
"
,
dwFlags
,
lpUnicodeCharStr
,
cchUnicodeChar
,
lpASCIICharStr
,
cchASCIIChar
);
SetLastError
(
ERROR_CALL_NOT_IMPLEMENTED
);
return
0
;
norm_len
=
IdnToNameprepUnicode
(
dwFlags
,
lpUnicodeCharStr
,
cchUnicodeChar
,
NULL
,
0
);
if
(
!
norm_len
)
return
0
;
norm_str
=
HeapAlloc
(
GetProcessHeap
(),
0
,
norm_len
*
sizeof
(
WCHAR
));
if
(
!
norm_str
)
{
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
0
;
}
norm_len
=
IdnToNameprepUnicode
(
dwFlags
,
lpUnicodeCharStr
,
cchUnicodeChar
,
norm_str
,
norm_len
);
if
(
!
norm_len
)
{
HeapFree
(
GetProcessHeap
(),
0
,
norm_str
);
return
0
;
}
for
(
label_start
=
0
;
label_start
<
norm_len
;)
{
INT
n
=
INIT_N
,
bias
=
INIT_BIAS
;
INT
delta
=
0
,
b
=
0
,
h
;
out_label
=
out
;
for
(
i
=
label_start
;
i
<
norm_len
&&
norm_str
[
i
]
!=
'.'
&&
norm_str
[
i
]
!=
'\0'
;
i
++
)
if
(
norm_str
[
i
]
<
0x80
)
b
++
;
label_end
=
i
;
if
(
b
==
label_end
-
label_start
)
{
if
(
label_end
<
norm_len
)
b
++
;
if
(
!
lpASCIICharStr
)
{
out
+=
b
;
}
else
if
(
out
+
b
<=
cchASCIIChar
)
{
memcpy
(
lpASCIICharStr
+
out
,
norm_str
+
label_start
,
b
*
sizeof
(
WCHAR
));
out
+=
b
;
}
else
{
HeapFree
(
GetProcessHeap
(),
0
,
norm_str
);
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
return
0
;
}
label_start
=
label_end
+
1
;
continue
;
}
if
(
!
lpASCIICharStr
)
{
out
+=
5
+
b
;
/* strlen(xn--...-) */
}
else
if
(
out
+
5
+
b
<=
cchASCIIChar
)
{
memcpy
(
lpASCIICharStr
+
out
,
prefixW
,
sizeof
(
prefixW
));
out
+=
4
;
for
(
i
=
label_start
;
i
<
label_end
;
i
++
)
if
(
norm_str
[
i
]
<
0x80
)
lpASCIICharStr
[
out
++
]
=
norm_str
[
i
];
lpASCIICharStr
[
out
++
]
=
'-'
;
}
else
{
HeapFree
(
GetProcessHeap
(),
0
,
norm_str
);
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
return
0
;
}
if
(
!
b
)
out
--
;
for
(
h
=
b
;
h
<
label_end
-
label_start
;)
{
INT
m
=
0xffff
,
q
,
k
;
for
(
i
=
label_start
;
i
<
label_end
;
i
++
)
{
if
(
norm_str
[
i
]
>=
n
&&
m
>
norm_str
[
i
])
m
=
norm_str
[
i
];
}
delta
+=
(
m
-
n
)
*
(
h
+
1
);
n
=
m
;
for
(
i
=
label_start
;
i
<
label_end
;
i
++
)
{
if
(
norm_str
[
i
]
<
n
)
{
delta
++
;
}
else
if
(
norm_str
[
i
]
==
n
)
{
for
(
q
=
delta
,
k
=
BASE
;
;
k
+=
BASE
)
{
INT
t
=
k
<=
bias
?
TMIN
:
k
>=
bias
+
TMAX
?
TMAX
:
k
-
bias
;
INT
disp
=
q
<
t
?
q
:
t
+
(
q
-
t
)
%
(
BASE
-
t
);
if
(
!
lpASCIICharStr
)
{
out
++
;
}
else
if
(
out
+
1
<=
cchASCIIChar
)
{
lpASCIICharStr
[
out
++
]
=
disp
<=
'z'
-
'a'
?
'a'
+
disp
:
'0'
+
disp
-
'z'
+
'a'
-
1
;
}
else
{
HeapFree
(
GetProcessHeap
(),
0
,
norm_str
);
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
return
0
;
}
if
(
q
<
t
)
break
;
q
=
(
q
-
t
)
/
(
BASE
-
t
);
}
bias
=
adapt
(
delta
,
h
+
1
,
h
==
b
);
delta
=
0
;
h
++
;
}
}
delta
++
;
n
++
;
}
if
(
out
-
out_label
>
63
)
{
HeapFree
(
GetProcessHeap
(),
0
,
norm_str
);
SetLastError
(
ERROR_INVALID_NAME
);
return
0
;
}
if
(
label_end
<
norm_len
)
{
if
(
!
lpASCIICharStr
)
{
out
++
;
}
else
if
(
out
+
1
<=
cchASCIIChar
)
{
lpASCIICharStr
[
out
++
]
=
norm_str
[
label_end
];
}
else
{
HeapFree
(
GetProcessHeap
(),
0
,
norm_str
);
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
return
0
;
}
}
label_start
=
label_end
+
1
;
}
HeapFree
(
GetProcessHeap
(),
0
,
norm_str
);
return
out
;
}
/******************************************************************************
...
...
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