2014-12-03 08:39:06 +00:00
|
|
|
/* Copyright (c) 2013-2014 Jeffrey Pfau
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2014-10-19 10:01:26 +00:00
|
|
|
#ifndef UTIL_STRING_H
|
|
|
|
#define UTIL_STRING_H
|
|
|
|
|
2016-12-31 01:00:22 +00:00
|
|
|
#include <mgba-util/common.h>
|
2014-10-19 10:01:26 +00:00
|
|
|
|
2016-12-27 05:01:55 +00:00
|
|
|
CXX_GUARD_START
|
|
|
|
|
2015-07-01 02:08:13 +00:00
|
|
|
#ifndef HAVE_STRNDUP
|
2014-11-17 04:25:52 +00:00
|
|
|
// This is sometimes a macro
|
2014-10-19 10:01:26 +00:00
|
|
|
char* strndup(const char* start, size_t len);
|
2014-11-17 04:25:52 +00:00
|
|
|
#endif
|
|
|
|
|
2015-07-01 02:08:13 +00:00
|
|
|
#ifndef HAVE_STRDUP
|
2015-06-15 06:25:49 +00:00
|
|
|
char* strdup(const char* str);
|
|
|
|
#endif
|
|
|
|
|
2020-07-06 23:08:23 +00:00
|
|
|
#ifndef HAVE_STRLCPY
|
|
|
|
size_t strlcpy(char* restrict dst, const char* restrict src, size_t dstsize);
|
|
|
|
#endif
|
|
|
|
|
2014-10-19 10:01:26 +00:00
|
|
|
char* strnrstr(const char* restrict s1, const char* restrict s2, size_t len);
|
2016-08-23 16:08:46 +00:00
|
|
|
bool endswith(const char* restrict s1, const char* restrict end);
|
2017-03-06 01:22:24 +00:00
|
|
|
bool startswith(const char* restrict s1, const char* restrict start);
|
2014-10-19 10:01:26 +00:00
|
|
|
|
2016-08-18 17:06:30 +00:00
|
|
|
size_t toUtf8(uint32_t unichar, char* buffer);
|
2021-04-23 07:18:18 +00:00
|
|
|
size_t toUtf16(uint32_t unichar, uint16_t* buffer);
|
2015-01-25 08:02:55 +00:00
|
|
|
int utfcmp(const uint16_t* utf16, const char* utf8, size_t utf16Length, size_t utf8Length);
|
|
|
|
char* utf16to8(const uint16_t* utf16, size_t length);
|
2015-11-01 17:33:07 +00:00
|
|
|
uint32_t utf8Char(const char** unicode, size_t* length);
|
|
|
|
uint32_t utf16Char(const uint16_t** unicode, size_t* length);
|
2019-06-30 21:51:27 +00:00
|
|
|
char* gbkToUtf8(const char* gbk, size_t length);
|
2015-01-25 08:02:55 +00:00
|
|
|
|
2015-04-09 07:41:00 +00:00
|
|
|
int hexDigit(char digit);
|
|
|
|
const char* hex32(const char* line, uint32_t* out);
|
2016-05-09 06:18:42 +00:00
|
|
|
const char* hex24(const char* line, uint32_t* out);
|
2015-04-09 07:41:00 +00:00
|
|
|
const char* hex16(const char* line, uint16_t* out);
|
2016-05-09 06:18:42 +00:00
|
|
|
const char* hex12(const char* line, uint16_t* out);
|
2015-12-27 03:25:50 +00:00
|
|
|
const char* hex8(const char* line, uint8_t* out);
|
2016-05-09 06:18:42 +00:00
|
|
|
const char* hex4(const char* line, uint8_t* out);
|
2015-04-09 07:41:00 +00:00
|
|
|
|
2016-08-19 12:06:45 +00:00
|
|
|
void rtrim(char* string);
|
|
|
|
|
2019-06-20 19:30:08 +00:00
|
|
|
ssize_t parseQuotedString(const char* unparsed, ssize_t unparsedLen, char* parsed, ssize_t parsedLen);
|
2020-07-27 04:56:09 +00:00
|
|
|
bool wildcard(const char* search, const char* string);
|
2019-06-20 19:30:08 +00:00
|
|
|
|
2016-12-27 05:01:55 +00:00
|
|
|
CXX_GUARD_END
|
|
|
|
|
2014-10-19 10:01:26 +00:00
|
|
|
#endif
|