all repos — mgba @ 3be21bf5954d73b7714620fd8e389ff94ec68157

mGBA Game Boy Advance Emulator

include/mgba-util/string.h (view raw)

 1/* Copyright (c) 2013-2014 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#ifndef UTIL_STRING_H
 7#define UTIL_STRING_H
 8
 9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#ifndef HAVE_STRNDUP
14// This is sometimes a macro
15char* strndup(const char* start, size_t len);
16#endif
17
18#ifndef HAVE_STRDUP
19char* strdup(const char* str);
20#endif
21
22char* strnrstr(const char* restrict s1, const char* restrict s2, size_t len);
23bool endswith(const char* restrict s1, const char* restrict end);
24bool startswith(const char* restrict s1, const char* restrict start);
25
26size_t toUtf8(uint32_t unichar, char* buffer);
27int utfcmp(const uint16_t* utf16, const char* utf8, size_t utf16Length, size_t utf8Length);
28char* utf16to8(const uint16_t* utf16, size_t length);
29uint32_t utf8Char(const char** unicode, size_t* length);
30uint32_t utf16Char(const uint16_t** unicode, size_t* length);
31char* gbkToUtf8(const char* gbk, size_t length);
32
33int hexDigit(char digit);
34const char* hex32(const char* line, uint32_t* out);
35const char* hex24(const char* line, uint32_t* out);
36const char* hex16(const char* line, uint16_t* out);
37const char* hex12(const char* line, uint16_t* out);
38const char* hex8(const char* line, uint8_t* out);
39const char* hex4(const char* line, uint8_t* out);
40
41void rtrim(char* string);
42
43ssize_t parseQuotedString(const char* unparsed, ssize_t unparsedLen, char* parsed, ssize_t parsedLen);
44
45CXX_GUARD_END
46
47#endif