os/arch/i686/strlib.c

45 lines
672 B
C
Raw Normal View History

2024-07-11 08:56:52 +02:00
#include <stddef.h>
size_t strlen(const char* str)
{
2024-08-13 15:24:17 +02:00
size_t len = 0;
while (str[len])
len++;
return len;
2024-07-11 08:56:52 +02:00
}
char to_upper_char(char c)
{
if ('a' <= c && c <= 'z') {
return c - 0x20;
} else {
return c;
}
}
char to_lower_char(char c)
{
if ('A' <= c && c <= 'Z') {
return c + 0x20;
} else {
return c;
}
}
char* to_lower_str(char* str)
{
for (size_t i = 0; i < strlen(str); i++) {
str[i] = to_lower_char(str[i]);
}
return str;
}
char* to_upper_str(char* str)
{
for (size_t i = 0; i < strlen(str); i++) {
str[i] = to_upper_char(str[i]);
}
return str;
}