Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2916304
utf8.h
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
utf8.h
View Options
#ifndef UTF8_H
#define UTF8_H
#include
<stddef.h>
#include
<stdint.h>
#include
<utf8proc.h>
size_t
utf8_char_len_at
(
const
char
*
str
,
size_t
byte_len
,
size_t
pos
);
size_t
utf8_strlen
(
const
char
*
str
,
size_t
byte_len
);
size_t
utf16_strlen
(
const
char
*
str
,
size_t
byte_len
);
int
utf16_index_to_byte_offset
(
const
char
*
str
,
size_t
byte_len
,
size_t
utf16_idx
,
size_t
*
out_char_bytes
);
int
utf16_range_to_byte_range
(
const
char
*
str
,
size_t
byte_len
,
size_t
utf16_start
,
size_t
utf16_end
,
size_t
*
byte_start
,
size_t
*
byte_end
);
uint32_t
utf16_code_unit_at
(
const
char
*
str
,
size_t
byte_len
,
size_t
utf16_idx
);
uint32_t
utf16_codepoint_at
(
const
char
*
str
,
size_t
byte_len
,
size_t
utf16_idx
);
static
inline
int
utf8_sequence_length
(
unsigned
char
first_byte
)
{
if
((
first_byte
&
0x80
)
==
0
)
return
1
;
if
((
first_byte
&
0xE0
)
==
0xC0
)
return
2
;
if
((
first_byte
&
0xF0
)
==
0xE0
)
return
3
;
if
((
first_byte
&
0xF8
)
==
0xF0
)
return
4
;
return
-1
;
}
static
inline
int
utf8_encode
(
uint32_t
cp
,
char
*
out
)
{
return
(
int
)
utf8proc_encode_char
((
utf8proc_int32_t
)
cp
,
(
utf8proc_uint8_t
*
)
out
);
}
static
inline
utf8proc_ssize_t
utf8_next
(
const
utf8proc_uint8_t
*
p
,
utf8proc_ssize_t
len
,
utf8proc_int32_t
*
cp
)
{
utf8proc_ssize_t
n
=
utf8proc_iterate
(
p
,
len
,
cp
);
return
n
>
0
?
n
:
1
;
}
#endif
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Thu, Mar 26, 4:46 PM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
511764
Default Alt Text
utf8.h (1 KB)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment