CORE_Static
This commit is contained in:
@@ -13,7 +13,7 @@ struct UTF32_Result{
|
||||
B32 error;
|
||||
};
|
||||
|
||||
function UTF32_Result
|
||||
CORE_Static UTF32_Result
|
||||
utf8_to_utf32(U8 *c, S64 max_advance) {
|
||||
UTF32_Result result = {};
|
||||
|
||||
@@ -73,7 +73,7 @@ struct UTF16_Result{
|
||||
B32 error;
|
||||
};
|
||||
|
||||
function UTF16_Result
|
||||
CORE_Static UTF16_Result
|
||||
utf32_to_utf16(U32 codepoint){
|
||||
UTF16_Result result = {};
|
||||
if (codepoint < 0x10000) {
|
||||
@@ -100,7 +100,7 @@ struct UTF8_Result{
|
||||
B32 error;
|
||||
};
|
||||
|
||||
function UTF8_Result
|
||||
CORE_Static UTF8_Result
|
||||
utf32_to_utf8(U32 codepoint) {
|
||||
UTF8_Result result = {};
|
||||
if (codepoint <= 0x7F) {
|
||||
@@ -132,7 +132,7 @@ utf32_to_utf8(U32 codepoint) {
|
||||
return result;
|
||||
}
|
||||
|
||||
function UTF32_Result
|
||||
CORE_Static UTF32_Result
|
||||
utf16_to_utf32(U16 *c, S32 max_advance) {
|
||||
UTF32_Result result = {};
|
||||
if(max_advance >= 1){
|
||||
@@ -158,7 +158,7 @@ utf16_to_utf32(U16 *c, S32 max_advance) {
|
||||
break; \
|
||||
}
|
||||
|
||||
function String32
|
||||
CORE_Static String32
|
||||
string16_to_string32(Arena *allocator, String16 string){
|
||||
String32 result = {arena_push_array(allocator, U32, string.len+1)};
|
||||
for(S64 i = 0; i < string.len;){
|
||||
@@ -174,7 +174,7 @@ string16_to_string32(Arena *allocator, String16 string){
|
||||
return result;
|
||||
}
|
||||
|
||||
function String32
|
||||
CORE_Static String32
|
||||
string8_to_string32(Arena *allocator, String string){
|
||||
String32 result = {arena_push_array(allocator, U32, string.len+1)};
|
||||
for(S64 i = 0; i < string.len;){
|
||||
@@ -189,7 +189,7 @@ string8_to_string32(Arena *allocator, String string){
|
||||
return result;
|
||||
}
|
||||
|
||||
function String16
|
||||
CORE_Static String16
|
||||
string8_to_string16(Arena *allocator, String in){
|
||||
String16 result = {arena_push_array(allocator, U16, (in.len*2)+1)}; // @Note(Krzosa): Should be more then enough space
|
||||
for(S64 i = 0; i < in.len;){
|
||||
@@ -211,7 +211,7 @@ string8_to_string16(Arena *allocator, String in){
|
||||
return result;
|
||||
}
|
||||
|
||||
function String
|
||||
CORE_Static String
|
||||
string16_to_string8(Arena *allocator, String16 in){
|
||||
String result = {arena_push_array(allocator, U8, in.len*4+1)};
|
||||
for(S64 i = 0; i < in.len;){
|
||||
@@ -232,7 +232,7 @@ string16_to_string8(Arena *allocator, String16 in){
|
||||
return result;
|
||||
}
|
||||
|
||||
function B32
|
||||
CORE_Static B32
|
||||
string_compare(String16 a, String16 b){
|
||||
if(a.len != b.len) return false;
|
||||
for(S64 i = 0; i < a.len; i++){
|
||||
@@ -241,7 +241,7 @@ string_compare(String16 a, String16 b){
|
||||
return true;
|
||||
}
|
||||
|
||||
function B32
|
||||
CORE_Static B32
|
||||
string_compare(String32 a, String32 b){
|
||||
if(a.len != b.len) return false;
|
||||
for(S64 i = 0; i < a.len; i++){
|
||||
@@ -250,14 +250,14 @@ string_compare(String32 a, String32 b){
|
||||
return true;
|
||||
}
|
||||
|
||||
function S64
|
||||
CORE_Static S64
|
||||
widechar_len(wchar_t *string){
|
||||
S64 len = 0;
|
||||
while(*string++!=0)len++;
|
||||
return len;
|
||||
}
|
||||
|
||||
function String16
|
||||
CORE_Static String16
|
||||
string16_from_widechar(wchar_t *string){
|
||||
String16 result;
|
||||
result.str = (U16 *)string;
|
||||
@@ -265,7 +265,7 @@ string16_from_widechar(wchar_t *string){
|
||||
return result;
|
||||
}
|
||||
|
||||
function String
|
||||
CORE_Static String
|
||||
string16_copy(Arena *a, String string){
|
||||
U8 *copy = arena_push_array(a, U8, string.len+1);
|
||||
memory_copy(copy, string.str, string.len);
|
||||
@@ -273,7 +273,7 @@ string16_copy(Arena *a, String string){
|
||||
return String{copy, string.len};
|
||||
}
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
test_unicode(){
|
||||
assert(utf8_to_utf32((U8 *)"A", 1).out_str == 'A');
|
||||
assert(utf8_to_utf32((U8 *)"ć", 2).out_str == 0x107);
|
||||
|
||||
Reference in New Issue
Block a user