ADDED: TextCopy() #1083
This commit is contained in:
parent
05443cd0c8
commit
5ec87c4c6f
2 changed files with 25 additions and 0 deletions
|
@ -1204,6 +1204,7 @@ RLAPI int GetGlyphIndex(Font font, int codepoint);
|
||||||
|
|
||||||
// Text strings management functions (no utf8 strings, only byte chars)
|
// Text strings management functions (no utf8 strings, only byte chars)
|
||||||
// NOTE: Some strings allocate memory internally for returned strings, just be careful!
|
// NOTE: Some strings allocate memory internally for returned strings, just be careful!
|
||||||
|
RLAPI int TextCopy(char *dst, const char *src); // Copy one string to another, returns bytes copied
|
||||||
RLAPI bool TextIsEqual(const char *text1, const char *text2); // Check if two text string are equal
|
RLAPI bool TextIsEqual(const char *text1, const char *text2); // Check if two text string are equal
|
||||||
RLAPI unsigned int TextLength(const char *text); // Get text length, checks for '\0' ending
|
RLAPI unsigned int TextLength(const char *text); // Get text length, checks for '\0' ending
|
||||||
RLAPI const char *TextFormat(const char *text, ...); // Text formatting with variables (sprintf style)
|
RLAPI const char *TextFormat(const char *text, ...); // Text formatting with variables (sprintf style)
|
||||||
|
|
24
src/text.c
24
src/text.c
|
@ -1105,8 +1105,32 @@ int GetGlyphIndex(Font font, int codepoint)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
// Text strings management functions
|
// Text strings management functions
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Copy one string to another, returns bytes copied
|
||||||
|
int TextCopy(char *dst, const char *src)
|
||||||
|
{
|
||||||
|
int bytes = 0;
|
||||||
|
|
||||||
|
if (dst != NULL)
|
||||||
|
{
|
||||||
|
while (*src != '\0')
|
||||||
|
{
|
||||||
|
*dst = *src;
|
||||||
|
dst++;
|
||||||
|
src++;
|
||||||
|
|
||||||
|
bytes++;
|
||||||
|
}
|
||||||
|
|
||||||
|
*dst = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if two text string are equal
|
// Check if two text string are equal
|
||||||
// REQUIRES: strcmp()
|
// REQUIRES: strcmp()
|
||||||
bool TextIsEqual(const char *text1, const char *text2)
|
bool TextIsEqual(const char *text1, const char *text2)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue