Skip to content

Commit 5ec87c4

Browse files
committed
ADDED: TextCopy() #1083
1 parent 05443cd commit 5ec87c4

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/raylib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,7 @@ RLAPI int GetGlyphIndex(Font font, int codepoint);
12041204

12051205
// Text strings management functions (no utf8 strings, only byte chars)
12061206
// NOTE: Some strings allocate memory internally for returned strings, just be careful!
1207+
RLAPI int TextCopy(char *dst, const char *src); // Copy one string to another, returns bytes copied
12071208
RLAPI bool TextIsEqual(const char *text1, const char *text2); // Check if two text string are equal
12081209
RLAPI unsigned int TextLength(const char *text); // Get text length, checks for '\0' ending
12091210
RLAPI const char *TextFormat(const char *text, ...); // Text formatting with variables (sprintf style)

src/text.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,8 +1105,32 @@ int GetGlyphIndex(Font font, int codepoint)
11051105
#endif
11061106
}
11071107

1108+
//----------------------------------------------------------------------------------
11081109
// Text strings management functions
11091110
//----------------------------------------------------------------------------------
1111+
1112+
// Copy one string to another, returns bytes copied
1113+
int TextCopy(char *dst, const char *src)
1114+
{
1115+
int bytes = 0;
1116+
1117+
if (dst != NULL)
1118+
{
1119+
while (*src != '\0')
1120+
{
1121+
*dst = *src;
1122+
dst++;
1123+
src++;
1124+
1125+
bytes++;
1126+
}
1127+
1128+
*dst = '\0';
1129+
}
1130+
1131+
return bytes;
1132+
}
1133+
11101134
// Check if two text string are equal
11111135
// REQUIRES: strcmp()
11121136
bool TextIsEqual(const char *text1, const char *text2)

0 commit comments

Comments
 (0)