add DLLEXPORT to all functions in mojibake.h
This commit is contained in:
parent
bc357b276f
commit
a840e5dae1
2
Makefile
2
Makefile
@ -6,7 +6,7 @@ MAKE=make
|
|||||||
|
|
||||||
# settings
|
# settings
|
||||||
|
|
||||||
cflags = -O2 -std=c99 -pedantic -Wall -fpic $(CFLAGS)
|
cflags = -O2 -std=c99 -pedantic -Wall -fpic -DLIBRARY_EXPORTS $(CFLAGS)
|
||||||
cc = $(CC) $(cflags)
|
cc = $(CC) $(cflags)
|
||||||
AR = ar
|
AR = ar
|
||||||
|
|
||||||
|
|||||||
40
mojibake.h
40
mojibake.h
@ -75,6 +75,16 @@ enum {false, true};
|
|||||||
#endif
|
#endif
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# ifdef LIBRARY_EXPORTS
|
||||||
|
# define DLLEXPORT __declspec(dllexport)
|
||||||
|
# else
|
||||||
|
# define DLLEXPORT __declspec(dllimport)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define DLLEXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -241,16 +251,16 @@ typedef struct utf8proc_property_struct {
|
|||||||
#define UTF8PROC_DECOMP_TYPE_FRACTION 15
|
#define UTF8PROC_DECOMP_TYPE_FRACTION 15
|
||||||
#define UTF8PROC_DECOMP_TYPE_COMPAT 16
|
#define UTF8PROC_DECOMP_TYPE_COMPAT 16
|
||||||
|
|
||||||
extern const int8_t utf8proc_utf8class[256];
|
DLLEXPORT extern const int8_t utf8proc_utf8class[256];
|
||||||
|
|
||||||
const char *utf8proc_version(void);
|
DLLEXPORT const char *utf8proc_version(void);
|
||||||
|
|
||||||
const char *utf8proc_errmsg(ssize_t errcode);
|
DLLEXPORT const char *utf8proc_errmsg(ssize_t errcode);
|
||||||
/*
|
/*
|
||||||
* Returns a static error string for the given error code.
|
* Returns a static error string for the given error code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ssize_t utf8proc_iterate(const uint8_t *str, ssize_t strlen, int32_t *dst);
|
DLLEXPORT ssize_t utf8proc_iterate(const uint8_t *str, ssize_t strlen, int32_t *dst);
|
||||||
/*
|
/*
|
||||||
* Reads a single char from the UTF-8 sequence being pointed to by 'str'.
|
* Reads a single char from the UTF-8 sequence being pointed to by 'str'.
|
||||||
* The maximum number of bytes read is 'strlen', unless 'strlen' is
|
* The maximum number of bytes read is 'strlen', unless 'strlen' is
|
||||||
@ -261,12 +271,12 @@ ssize_t utf8proc_iterate(const uint8_t *str, ssize_t strlen, int32_t *dst);
|
|||||||
* negative error code is returned.
|
* negative error code is returned.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool utf8proc_codepoint_valid(int32_t uc);
|
DLLEXPORT bool utf8proc_codepoint_valid(int32_t uc);
|
||||||
/*
|
/*
|
||||||
* Returns 1, if the given unicode code-point is valid, otherwise 0.
|
* Returns 1, if the given unicode code-point is valid, otherwise 0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ssize_t utf8proc_encode_char(int32_t uc, uint8_t *dst);
|
DLLEXPORT ssize_t utf8proc_encode_char(int32_t uc, uint8_t *dst);
|
||||||
/*
|
/*
|
||||||
* Encodes the unicode char with the code point 'uc' as an UTF-8 string in
|
* Encodes the unicode char with the code point 'uc' as an UTF-8 string in
|
||||||
* the byte array being pointed to by 'dst'. This array has to be at least
|
* the byte array being pointed to by 'dst'. This array has to be at least
|
||||||
@ -276,7 +286,7 @@ ssize_t utf8proc_encode_char(int32_t uc, uint8_t *dst);
|
|||||||
* This function does not check if 'uc' is a valid unicode code point.
|
* This function does not check if 'uc' is a valid unicode code point.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const utf8proc_property_t *utf8proc_get_property(int32_t uc);
|
DLLEXPORT const utf8proc_property_t *utf8proc_get_property(int32_t uc);
|
||||||
/*
|
/*
|
||||||
* Returns a pointer to a (constant) struct containing information about
|
* Returns a pointer to a (constant) struct containing information about
|
||||||
* the unicode char with the given code point 'uc'.
|
* the unicode char with the given code point 'uc'.
|
||||||
@ -286,7 +296,7 @@ const utf8proc_property_t *utf8proc_get_property(int32_t uc);
|
|||||||
* 0x10FFFF, otherwise the program might crash!
|
* 0x10FFFF, otherwise the program might crash!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ssize_t utf8proc_decompose_char(
|
DLLEXPORT ssize_t utf8proc_decompose_char(
|
||||||
int32_t uc, int32_t *dst, ssize_t bufsize,
|
int32_t uc, int32_t *dst, ssize_t bufsize,
|
||||||
int options, int *last_boundclass
|
int options, int *last_boundclass
|
||||||
);
|
);
|
||||||
@ -314,7 +324,7 @@ ssize_t utf8proc_decompose_char(
|
|||||||
* 0x10FFFF, otherwise the program might crash!
|
* 0x10FFFF, otherwise the program might crash!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ssize_t utf8proc_decompose(
|
DLLEXPORT ssize_t utf8proc_decompose(
|
||||||
const uint8_t *str, ssize_t strlen,
|
const uint8_t *str, ssize_t strlen,
|
||||||
int32_t *buffer, ssize_t bufsize, int options
|
int32_t *buffer, ssize_t bufsize, int options
|
||||||
);
|
);
|
||||||
@ -332,7 +342,7 @@ ssize_t utf8proc_decompose(
|
|||||||
* buffer size is returned.
|
* buffer size is returned.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options);
|
DLLEXPORT ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options);
|
||||||
/*
|
/*
|
||||||
* Reencodes the sequence of unicode characters given by the pointer
|
* Reencodes the sequence of unicode characters given by the pointer
|
||||||
* 'buffer' and 'length' as UTF-8.
|
* 'buffer' and 'length' as UTF-8.
|
||||||
@ -355,7 +365,7 @@ ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options);
|
|||||||
* crash!
|
* crash!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ssize_t utf8proc_map(
|
DLLEXPORT ssize_t utf8proc_map(
|
||||||
const uint8_t *str, ssize_t strlen, uint8_t **dstptr, int options
|
const uint8_t *str, ssize_t strlen, uint8_t **dstptr, int options
|
||||||
);
|
);
|
||||||
/*
|
/*
|
||||||
@ -374,10 +384,10 @@ ssize_t utf8proc_map(
|
|||||||
* 'malloc', and has theirfore to be freed with 'free'.
|
* 'malloc', and has theirfore to be freed with 'free'.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint8_t *utf8proc_NFD(const uint8_t *str);
|
DLLEXPORT uint8_t *utf8proc_NFD(const uint8_t *str);
|
||||||
uint8_t *utf8proc_NFC(const uint8_t *str);
|
DLLEXPORT uint8_t *utf8proc_NFC(const uint8_t *str);
|
||||||
uint8_t *utf8proc_NFKD(const uint8_t *str);
|
DLLEXPORT uint8_t *utf8proc_NFKD(const uint8_t *str);
|
||||||
uint8_t *utf8proc_NFKC(const uint8_t *str);
|
DLLEXPORT uint8_t *utf8proc_NFKC(const uint8_t *str);
|
||||||
/*
|
/*
|
||||||
* Returns a pointer to newly allocated memory of a NFD, NFC, NFKD or NFKC
|
* Returns a pointer to newly allocated memory of a NFD, NFC, NFKD or NFKC
|
||||||
* normalized version of the null-terminated string 'str'.
|
* normalized version of the null-terminated string 'str'.
|
||||||
|
|||||||
30
utf8proc.c
30
utf8proc.c
@ -43,7 +43,7 @@
|
|||||||
#include "utf8proc_data.c"
|
#include "utf8proc_data.c"
|
||||||
|
|
||||||
|
|
||||||
const int8_t utf8proc_utf8class[256] = {
|
DLLEXPORT const int8_t utf8proc_utf8class[256] = {
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
@ -95,11 +95,11 @@ const int8_t utf8proc_utf8class[256] = {
|
|||||||
#define UTF8PROC_BOUNDCLASS_LVT 10
|
#define UTF8PROC_BOUNDCLASS_LVT 10
|
||||||
|
|
||||||
|
|
||||||
const char *utf8proc_version(void) {
|
DLLEXPORT const char *utf8proc_version(void) {
|
||||||
return "1.1.6";
|
return "1.1.6";
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *utf8proc_errmsg(ssize_t errcode) {
|
DLLEXPORT const char *utf8proc_errmsg(ssize_t errcode) {
|
||||||
switch (errcode) {
|
switch (errcode) {
|
||||||
case UTF8PROC_ERROR_NOMEM:
|
case UTF8PROC_ERROR_NOMEM:
|
||||||
return "Memory for processing UTF-8 data could not be allocated.";
|
return "Memory for processing UTF-8 data could not be allocated.";
|
||||||
@ -116,7 +116,7 @@ const char *utf8proc_errmsg(ssize_t errcode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t utf8proc_iterate(
|
DLLEXPORT ssize_t utf8proc_iterate(
|
||||||
const uint8_t *str, ssize_t strlen, int32_t *dst
|
const uint8_t *str, ssize_t strlen, int32_t *dst
|
||||||
) {
|
) {
|
||||||
int length;
|
int length;
|
||||||
@ -156,14 +156,14 @@ ssize_t utf8proc_iterate(
|
|||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool utf8proc_codepoint_valid(int32_t uc) {
|
DLLEXPORT bool utf8proc_codepoint_valid(int32_t uc) {
|
||||||
if (uc < 0 || uc >= 0x110000 ||
|
if (uc < 0 || uc >= 0x110000 ||
|
||||||
((uc & 0xFFFF) >= 0xFFFE) || (uc >= 0xD800 && uc < 0xE000) ||
|
((uc & 0xFFFF) >= 0xFFFE) || (uc >= 0xD800 && uc < 0xE000) ||
|
||||||
(uc >= 0xFDD0 && uc < 0xFDF0)) return false;
|
(uc >= 0xFDD0 && uc < 0xFDF0)) return false;
|
||||||
else return true;
|
else return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t utf8proc_encode_char(int32_t uc, uint8_t *dst) {
|
DLLEXPORT ssize_t utf8proc_encode_char(int32_t uc, uint8_t *dst) {
|
||||||
if (uc < 0x00) {
|
if (uc < 0x00) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (uc < 0x80) {
|
} else if (uc < 0x80) {
|
||||||
@ -193,7 +193,7 @@ ssize_t utf8proc_encode_char(int32_t uc, uint8_t *dst) {
|
|||||||
} else return 0;
|
} else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const utf8proc_property_t *utf8proc_get_property(int32_t uc) {
|
DLLEXPORT const utf8proc_property_t *utf8proc_get_property(int32_t uc) {
|
||||||
/* ASSERT: uc >= 0 && uc < 0x110000 */
|
/* ASSERT: uc >= 0 && uc < 0x110000 */
|
||||||
return utf8proc_properties + (
|
return utf8proc_properties + (
|
||||||
utf8proc_stage2table[
|
utf8proc_stage2table[
|
||||||
@ -206,7 +206,7 @@ const utf8proc_property_t *utf8proc_get_property(int32_t uc) {
|
|||||||
return utf8proc_decompose_char((replacement_uc), dst, bufsize, \
|
return utf8proc_decompose_char((replacement_uc), dst, bufsize, \
|
||||||
options & ~UTF8PROC_LUMP, last_boundclass)
|
options & ~UTF8PROC_LUMP, last_boundclass)
|
||||||
|
|
||||||
ssize_t utf8proc_decompose_char(int32_t uc, int32_t *dst, ssize_t bufsize,
|
DLLEXPORT ssize_t utf8proc_decompose_char(int32_t uc, int32_t *dst, ssize_t bufsize,
|
||||||
int options, int *last_boundclass) {
|
int options, int *last_boundclass) {
|
||||||
/* ASSERT: uc >= 0 && uc < 0x110000 */
|
/* ASSERT: uc >= 0 && uc < 0x110000 */
|
||||||
const utf8proc_property_t *property;
|
const utf8proc_property_t *property;
|
||||||
@ -351,7 +351,7 @@ ssize_t utf8proc_decompose_char(int32_t uc, int32_t *dst, ssize_t bufsize,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t utf8proc_decompose(
|
DLLEXPORT ssize_t utf8proc_decompose(
|
||||||
const uint8_t *str, ssize_t strlen,
|
const uint8_t *str, ssize_t strlen,
|
||||||
int32_t *buffer, ssize_t bufsize, int options
|
int32_t *buffer, ssize_t bufsize, int options
|
||||||
) {
|
) {
|
||||||
@ -413,7 +413,7 @@ ssize_t utf8proc_decompose(
|
|||||||
return wpos;
|
return wpos;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options) {
|
DLLEXPORT ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options) {
|
||||||
/* UTF8PROC_NULLTERM option will be ignored, 'length' is never ignored
|
/* UTF8PROC_NULLTERM option will be ignored, 'length' is never ignored
|
||||||
ASSERT: 'buffer' has one spare byte of free space at the end! */
|
ASSERT: 'buffer' has one spare byte of free space at the end! */
|
||||||
if (options & (UTF8PROC_NLF2LS | UTF8PROC_NLF2PS | UTF8PROC_STRIPCC)) {
|
if (options & (UTF8PROC_NLF2LS | UTF8PROC_NLF2PS | UTF8PROC_STRIPCC)) {
|
||||||
@ -528,7 +528,7 @@ ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t utf8proc_map(
|
DLLEXPORT ssize_t utf8proc_map(
|
||||||
const uint8_t *str, ssize_t strlen, uint8_t **dstptr, int options
|
const uint8_t *str, ssize_t strlen, uint8_t **dstptr, int options
|
||||||
) {
|
) {
|
||||||
int32_t *buffer;
|
int32_t *buffer;
|
||||||
@ -557,28 +557,28 @@ ssize_t utf8proc_map(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *utf8proc_NFD(const uint8_t *str) {
|
DLLEXPORT uint8_t *utf8proc_NFD(const uint8_t *str) {
|
||||||
uint8_t *retval;
|
uint8_t *retval;
|
||||||
utf8proc_map(str, 0, &retval, UTF8PROC_NULLTERM | UTF8PROC_STABLE |
|
utf8proc_map(str, 0, &retval, UTF8PROC_NULLTERM | UTF8PROC_STABLE |
|
||||||
UTF8PROC_DECOMPOSE);
|
UTF8PROC_DECOMPOSE);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *utf8proc_NFC(const uint8_t *str) {
|
DLLEXPORT uint8_t *utf8proc_NFC(const uint8_t *str) {
|
||||||
uint8_t *retval;
|
uint8_t *retval;
|
||||||
utf8proc_map(str, 0, &retval, UTF8PROC_NULLTERM | UTF8PROC_STABLE |
|
utf8proc_map(str, 0, &retval, UTF8PROC_NULLTERM | UTF8PROC_STABLE |
|
||||||
UTF8PROC_COMPOSE);
|
UTF8PROC_COMPOSE);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *utf8proc_NFKD(const uint8_t *str) {
|
DLLEXPORT uint8_t *utf8proc_NFKD(const uint8_t *str) {
|
||||||
uint8_t *retval;
|
uint8_t *retval;
|
||||||
utf8proc_map(str, 0, &retval, UTF8PROC_NULLTERM | UTF8PROC_STABLE |
|
utf8proc_map(str, 0, &retval, UTF8PROC_NULLTERM | UTF8PROC_STABLE |
|
||||||
UTF8PROC_DECOMPOSE | UTF8PROC_COMPAT);
|
UTF8PROC_DECOMPOSE | UTF8PROC_COMPAT);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *utf8proc_NFKC(const uint8_t *str) {
|
DLLEXPORT uint8_t *utf8proc_NFKC(const uint8_t *str) {
|
||||||
uint8_t *retval;
|
uint8_t *retval;
|
||||||
utf8proc_map(str, 0, &retval, UTF8PROC_NULLTERM | UTF8PROC_STABLE |
|
utf8proc_map(str, 0, &retval, UTF8PROC_NULLTERM | UTF8PROC_STABLE |
|
||||||
UTF8PROC_COMPOSE | UTF8PROC_COMPAT);
|
UTF8PROC_COMPOSE | UTF8PROC_COMPAT);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user