toUpper, toLower
This commit is contained in:
parent
5d275c8dd1
commit
422d967165
@ -100,9 +100,26 @@ bool str_endsWith(str src, str fragment){
|
||||
|
||||
u32 str_hash32(str s){
|
||||
u8* ubuf = (u8*)s.data;
|
||||
u32 len = s.len;
|
||||
u32 hash=0;
|
||||
for (u32 i = 0; i < len; i++)
|
||||
for (u32 i = 0; i < s.len; i++)
|
||||
hash = (hash<<6) + (hash<<16) - hash + ubuf[i];
|
||||
return hash;
|
||||
}
|
||||
|
||||
str str_toUpper(str src){
|
||||
str r = str_copy(src);
|
||||
for (u32 i = 0; i < r.len; i++){
|
||||
if(isAlphabeticalLower(r.data[i]))
|
||||
r.data[i] = r.data[i] - 'a' + 'A';
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
str str_toLower(str src){
|
||||
str r = str_copy(src);
|
||||
for (u32 i = 0; i < r.len; i++){
|
||||
if(isAlphabeticalUpper(r.data[i]))
|
||||
r.data[i] = r.data[i] - 'A' + 'a';
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -36,3 +36,6 @@ bool str_endsWith(str src, str fragment);
|
||||
/// @brief calculates string hash using sdbm32 algorythm (something like lightweight crc32)
|
||||
/// @return non-cryptografic hash of the string
|
||||
u32 str_hash32(str s);
|
||||
|
||||
str str_toUpper(str src);
|
||||
str str_toLower(str src);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user