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
b2c4a5db
Commit
b2c4a5db
authored
Oct 14, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/UTF8: use `uint8_t` instead of `unsigned char`
parent
cadfccfd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
21 deletions
+23
-21
UTF8.cxx
src/util/UTF8.cxx
+23
-21
No files found.
src/util/UTF8.cxx
View file @
b2c4a5db
...
...
@@ -33,17 +33,19 @@
#include <algorithm>
#include <stdint.h>
/**
* Is this a leading byte that is followed by 1 continuation byte?
*/
static
constexpr
bool
IsLeading1
(
u
nsigned
char
ch
)
noexcept
IsLeading1
(
u
int8_t
ch
)
noexcept
{
return
(
ch
&
0xe0
)
==
0xc0
;
}
static
constexpr
u
nsigned
char
MakeLeading1
(
u
nsigned
char
value
)
noexcept
static
constexpr
u
int8_t
MakeLeading1
(
u
int8_t
value
)
noexcept
{
return
0xc0
|
value
;
}
...
...
@@ -52,13 +54,13 @@ MakeLeading1(unsigned char value) noexcept
* Is this a leading byte that is followed by 2 continuation byte?
*/
static
constexpr
bool
IsLeading2
(
u
nsigned
char
ch
)
noexcept
IsLeading2
(
u
int8_t
ch
)
noexcept
{
return
(
ch
&
0xf0
)
==
0xe0
;
}
static
constexpr
u
nsigned
char
MakeLeading2
(
u
nsigned
char
value
)
noexcept
static
constexpr
u
int8_t
MakeLeading2
(
u
int8_t
value
)
noexcept
{
return
0xe0
|
value
;
}
...
...
@@ -67,13 +69,13 @@ MakeLeading2(unsigned char value) noexcept
* Is this a leading byte that is followed by 3 continuation byte?
*/
static
constexpr
bool
IsLeading3
(
u
nsigned
char
ch
)
noexcept
IsLeading3
(
u
int8_t
ch
)
noexcept
{
return
(
ch
&
0xf8
)
==
0xf0
;
}
static
constexpr
u
nsigned
char
MakeLeading3
(
u
nsigned
char
value
)
noexcept
static
constexpr
u
int8_t
MakeLeading3
(
u
int8_t
value
)
noexcept
{
return
0xf0
|
value
;
}
...
...
@@ -82,13 +84,13 @@ MakeLeading3(unsigned char value) noexcept
* Is this a leading byte that is followed by 4 continuation byte?
*/
static
constexpr
bool
IsLeading4
(
u
nsigned
char
ch
)
noexcept
IsLeading4
(
u
int8_t
ch
)
noexcept
{
return
(
ch
&
0xfc
)
==
0xf8
;
}
static
constexpr
u
nsigned
char
MakeLeading4
(
u
nsigned
char
value
)
noexcept
static
constexpr
u
int8_t
MakeLeading4
(
u
int8_t
value
)
noexcept
{
return
0xf8
|
value
;
}
...
...
@@ -97,19 +99,19 @@ MakeLeading4(unsigned char value) noexcept
* Is this a leading byte that is followed by 5 continuation byte?
*/
static
constexpr
bool
IsLeading5
(
u
nsigned
char
ch
)
noexcept
IsLeading5
(
u
int8_t
ch
)
noexcept
{
return
(
ch
&
0xfe
)
==
0xfc
;
}
static
constexpr
u
nsigned
char
MakeLeading5
(
u
nsigned
char
value
)
noexcept
static
constexpr
u
int8_t
MakeLeading5
(
u
int8_t
value
)
noexcept
{
return
0xfc
|
value
;
}
static
constexpr
bool
IsContinuation
(
u
nsigned
char
ch
)
noexcept
IsContinuation
(
u
int8_t
ch
)
noexcept
{
return
(
ch
&
0xc0
)
==
0x80
;
}
...
...
@@ -117,8 +119,8 @@ IsContinuation(unsigned char ch) noexcept
/**
* Generate a continuation byte of the low 6 bit.
*/
static
constexpr
u
nsigned
char
MakeContinuation
(
u
nsigned
char
value
)
noexcept
static
constexpr
u
int8_t
MakeContinuation
(
u
int8_t
value
)
noexcept
{
return
0x80
|
(
value
&
0x3f
);
}
...
...
@@ -127,7 +129,7 @@ bool
ValidateUTF8
(
const
char
*
p
)
noexcept
{
for
(;
*
p
!=
0
;
++
p
)
{
u
nsigned
char
ch
=
*
p
;
u
int8_t
ch
=
*
p
;
if
(
IsASCII
(
ch
))
continue
;
...
...
@@ -221,7 +223,7 @@ InnerSequenceLengthUTF8(const char *p) noexcept
size_t
SequenceLengthUTF8
(
const
char
*
p
)
noexcept
{
const
u
nsigned
char
ch
=
*
p
++
;
const
u
int8_t
ch
=
*
p
++
;
if
(
IsASCII
(
ch
))
return
1
;
...
...
@@ -272,7 +274,7 @@ Latin1ToUTF8(const char *gcc_restrict src, char *gcc_restrict buffer,
char
*
q
=
std
::
copy
(
src
,
p
,
buffer
);
while
(
*
p
!=
0
)
{
u
nsigned
char
ch
=
*
p
++
;
u
int8_t
ch
=
*
p
++
;
if
(
IsASCII
(
ch
))
{
*
q
++
=
ch
;
...
...
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