mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2025-04-16 21:46:03 +02:00
stdlib: added SDL_utf8strlen().
This commit is contained in:
parent
fc510bd798
commit
d4086e4a70
@ -416,6 +416,7 @@ extern DECLSPEC char *SDLCALL SDL_strlwr(char *str);
|
|||||||
extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c);
|
extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c);
|
||||||
extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
|
extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
|
||||||
extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
|
extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
|
||||||
|
extern DECLSPEC size_t SDLCALL SDL_utf8strlen(const char *str);
|
||||||
|
|
||||||
extern DECLSPEC char *SDLCALL SDL_itoa(int value, char *str, int radix);
|
extern DECLSPEC char *SDLCALL SDL_itoa(int value, char *str, int radix);
|
||||||
extern DECLSPEC char *SDLCALL SDL_uitoa(unsigned int value, char *str, int radix);
|
extern DECLSPEC char *SDLCALL SDL_uitoa(unsigned int value, char *str, int radix);
|
||||||
|
@ -624,3 +624,4 @@
|
|||||||
#define SDL_MemoryBarrierReleaseFunction SDL_MemoryBarrierReleaseFunction_REAL
|
#define SDL_MemoryBarrierReleaseFunction SDL_MemoryBarrierReleaseFunction_REAL
|
||||||
#define SDL_MemoryBarrierAcquireFunction SDL_MemoryBarrierAcquireFunction_REAL
|
#define SDL_MemoryBarrierAcquireFunction SDL_MemoryBarrierAcquireFunction_REAL
|
||||||
#define SDL_JoystickGetDeviceInstanceID SDL_JoystickGetDeviceInstanceID_REAL
|
#define SDL_JoystickGetDeviceInstanceID SDL_JoystickGetDeviceInstanceID_REAL
|
||||||
|
#define SDL_utf8strlen SDL_utf8strlen_REAL
|
||||||
|
@ -656,3 +656,4 @@ SDL_DYNAPI_PROC(SDL_JoystickType,SDL_JoystickGetType,(SDL_Joystick *a),(a),retur
|
|||||||
SDL_DYNAPI_PROC(void,SDL_MemoryBarrierReleaseFunction,(void),(),)
|
SDL_DYNAPI_PROC(void,SDL_MemoryBarrierReleaseFunction,(void),(),)
|
||||||
SDL_DYNAPI_PROC(void,SDL_MemoryBarrierAcquireFunction,(void),(),)
|
SDL_DYNAPI_PROC(void,SDL_MemoryBarrierAcquireFunction,(void),(),)
|
||||||
SDL_DYNAPI_PROC(SDL_JoystickID,SDL_JoystickGetDeviceInstanceID,(int a),(a),return)
|
SDL_DYNAPI_PROC(SDL_JoystickID,SDL_JoystickGetDeviceInstanceID,(int a),(a),return)
|
||||||
|
SDL_DYNAPI_PROC(size_t,SDL_utf8strlen,(const char *a),(a),return)
|
||||||
|
@ -509,6 +509,23 @@ size_t SDL_utf8strlcpy(SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
SDL_utf8strlen(const char *str)
|
||||||
|
{
|
||||||
|
size_t retval = 0;
|
||||||
|
const char *p = str;
|
||||||
|
char ch;
|
||||||
|
|
||||||
|
while ((ch = *(p++))) {
|
||||||
|
/* if top two bits are 1 and 0, it's a continuation byte. */
|
||||||
|
if ((ch & 0xc0) != 0x80) {
|
||||||
|
retval++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
|
SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user