cstring helper for wide chars

This commit is contained in:
Nikita Smith
2024-10-18 22:56:55 -07:00
parent 9d60dcc099
commit f1a0e7233d
2 changed files with 16 additions and 4 deletions
+15 -4
View File
@@ -215,12 +215,23 @@ str32_cstring(U32 *c){
internal String8
str8_cstring_capped(void *cstr, void *cap)
{
char *ptr = (char*)cstr;
char *opl = (char*)cap;
char *ptr = cstr;
char *opl = cap;
for (;ptr < opl && *ptr != 0; ptr += 1);
U64 size = (U64)(ptr - (char *)cstr);
String8 result = {(U8*)cstr, size};
return(result);
String8 result = str8((U8*)cstr, size);
return result;
}
internal String16
str16_cstring_capped(void *cstr, void *cap)
{
U16 *ptr = cstr;
U16 *opl = cap;
for (;ptr < opl && *ptr != 0; ptr += 1);
U64 size = (U64)(ptr - (U16 *)cstr);
String16 result = str16(cstr, size);
return result;
}
////////////////////////////////
+1
View File
@@ -193,6 +193,7 @@ internal String8 str8_cstring(char *c);
internal String16 str16_cstring(U16 *c);
internal String32 str32_cstring(U32 *c);
internal String8 str8_cstring_capped(void *cstr, void *cap);
internal String16 str16_cstring_capped(void *cstr, void *cap);
////////////////////////////////
//~ rjf: String Stylization