Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Иван Мажукин
mpd
Commits
21f17270
Commit
21f17270
authored
Apr 21, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/icu/Util: UCharFromUTF8() throws on error
parent
423cd590
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
8 deletions
+15
-8
Collate.cxx
src/lib/icu/Collate.cxx
+9
-6
Converter.cxx
src/lib/icu/Converter.cxx
+3
-1
Util.cxx
src/lib/icu/Util.cxx
+1
-1
Util.hxx
src/lib/icu/Util.hxx
+2
-0
No files found.
src/lib/icu/Collate.cxx
View file @
21f17270
...
...
@@ -99,13 +99,16 @@ IcuCollate(const char *a, const char *b)
#else
/* fall back to ucol_strcoll() */
const
auto
au
=
UCharFromUTF8
(
a
);
const
auto
bu
=
UCharFromUTF8
(
b
);
try
{
const
auto
au
=
UCharFromUTF8
(
a
);
const
auto
bu
=
UCharFromUTF8
(
b
);
return
!
au
.
IsNull
()
&&
!
bu
.
IsNull
()
?
(
int
)
ucol_strcoll
(
collator
,
au
.
begin
(),
au
.
size
(),
bu
.
begin
(),
bu
.
size
())
:
strcasecmp
(
a
,
b
);
return
ucol_strcoll
(
collator
,
au
.
begin
(),
au
.
size
(),
bu
.
begin
(),
bu
.
size
());
}
catch
(
const
std
::
runtime_error
&
)
{
/* fall back to plain strcasecmp() */
return
strcasecmp
(
a
,
b
);
}
#endif
#elif defined(WIN32)
...
...
src/lib/icu/Converter.cxx
View file @
21f17270
...
...
@@ -129,7 +129,7 @@ try {
AllocatedString
<
char
>
IcuConverter
::
FromUTF8
(
const
char
*
s
)
const
{
try
{
#ifdef HAVE_ICU
const
ScopeLock
protect
(
mutex
);
...
...
@@ -156,6 +156,8 @@ IcuConverter::FromUTF8(const char *s) const
#elif defined(HAVE_ICONV)
return
DoConvert
(
from_utf8
,
s
);
#endif
}
catch
(
const
std
::
runtime_error
&
)
{
return
nullptr
;
}
#endif
src/lib/icu/Util.cxx
View file @
21f17270
...
...
@@ -47,7 +47,7 @@ UCharFromUTF8(const char *src)
src
,
src_length
,
&
error_code
);
if
(
U_FAILURE
(
error_code
))
return
{}
;
throw
std
::
runtime_error
(
u_errorName
(
error_code
))
;
dest
.
SetSize
(
dest_length
);
return
dest
;
...
...
src/lib/icu/Util.hxx
View file @
21f17270
...
...
@@ -30,6 +30,8 @@ template<typename T> class AllocatedString;
/**
* Wrapper for u_strFromUTF8().
*
* Throws std::runtime_error on error.
*/
AllocatedArray
<
UChar
>
UCharFromUTF8
(
const
char
*
src
);
...
...
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