Skip to content

Commit

Permalink
Added func to convert string to unsigned char*.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chukobyte committed Dec 13, 2023
1 parent 42cec1e commit 2a1fb76
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions seika/utils/se_string_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ char* se_str_to_lower_and_underscore_whitespace(char* str) {
return str;
}

unsigned char* se_str_convert_string_to_unsigned_char(const char* value, size_t* outSize) {
const size_t stringLength = strlen(value);
*outSize = stringLength + 1;
unsigned char* returnValue = (unsigned char*)SE_MEM_ALLOCATE_SIZE(*outSize);
for (size_t i = 0; i < stringLength; i++) {
returnValue[i] = (unsigned char)value[i];
}
returnValue[stringLength] = '\0';
return returnValue;
}

char* se_str_trim(const char* value, char delimiter) {
char* newStr;
char* lastExt;
Expand Down
4 changes: 4 additions & 0 deletions seika/utils/se_string_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ void se_strcpy(char* destination, const char* source);
bool se_strncpy(char* destination, size_t sizeInBytes, const char* source, size_t maxCount);
void se_strcat(char* destination, const char* source);
void se_strncat(char* destination, const char* source, size_t sizeInBytes);
// Conversions

const char* se_bool_to_string(bool value);
char* se_str_to_lower();
char* se_str_to_lower_and_underscore_whitespace(char* str);
unsigned char* se_str_convert_string_to_unsigned_char(const char* value, size_t* outSize);

// Will trim text based on a delimiter and return the string before that
char* se_str_trim(const char* value, char delimiter);
// Will trim text based on a size and return the string as the 'output' param
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "seika",
"version": "0.0.7",
"version": "0.0.8",
"dependencies": [
{
"name": "sdl2",
Expand Down

0 comments on commit 2a1fb76

Please sign in to comment.