diff options
Diffstat (limited to 'src/charset/codecs/codec_utf8.c')
-rw-r--r-- | src/charset/codecs/codec_utf8.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/charset/codecs/codec_utf8.c b/src/charset/codecs/codec_utf8.c index 7ef7fb8..ceae951 100644 --- a/src/charset/codecs/codec_utf8.c +++ b/src/charset/codecs/codec_utf8.c @@ -8,19 +8,11 @@ #include <stdlib.h> #include <string.h> -#ifdef BUILD_TARGET_windows -#include <winsock.h> -#else -/* These three are for htonl / ntohl */ -#include <sys/types.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#endif - #include <parserutils/charset/mibenum.h> #include "charset/codecs/codec_impl.h" #include "charset/encodings/utf8impl.h" +#include "utils/endian.h" #include "utils/utils.h" /** @@ -206,7 +198,7 @@ parserutils_error charset_utf8_codec_encode(parserutils_charset_codec *codec, /* Now process the characters for this call */ while (*sourcelen > 0) { - ucs4 = (uint32_t) ntohl(*((uint32_t *) (void *) *source)); + ucs4 = endian_big_to_host(*((uint32_t *) (void *) *source)); towrite = &ucs4; towritelen = 1; @@ -302,7 +294,7 @@ parserutils_error charset_utf8_codec_decode(parserutils_charset_codec *codec, while (c->read_len > 0 && *destlen >= c->read_len * 4) { *((uint32_t *) (void *) *dest) = - (uint32_t) htonl(pread[0]); + endian_host_to_big(pread[0]); *dest += 4; *destlen -= 4; @@ -548,7 +540,7 @@ parserutils_error charset_utf8_codec_output_decoded_char(charset_utf8_codec *c, return PARSERUTILS_NOMEM; } - *((uint32_t *) (void *) *dest) = (uint32_t) htonl(ucs4); + *((uint32_t *) (void *) *dest) = endian_host_to_big(ucs4); *dest += 4; *destlen -= 4; |