/
nirinis
/
MalachiteDSL
Обзор
Документация
Войти
/
nirinis
/
MalachiteDSL
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
source/utils/strings/madsl_encoding.c
44 строки
1 KB
nirinis
Appending of fundamental files
02 авг 2026, 18:43
Верифицирован
02 авг 2026, 18:43
17af66b
Код
Авторство
О чём код?
#include "..\..\..\include\utils\strings\madsl_encoding.h" madsl_byte_ptr madsl_get_encoding_char_ptr(const char* string, size_t size, size_t start_index, uint32_t encoding) { if (start_index >= size) return madsl_null_byte_ptr(); madsl_byte_ptr result; result.pointer = string + start_index; switch (encoding) { case MADSL_ASCII: { result.size = 1; } break; case MADSL_UTF8: { madsl_byte first = string[start_index]; if ((first & 0x80) == 0) { // ASCII: 0xxxxxxx result.size = 1; } else { uint8_t count_of_bytes = 0; uint8_t mask = 0x80; // ������� ��� while (first & mask) { count_of_bytes++; mask >>= 1; } // count_of_bytes ������ ����� ���������� ������� ������ // ���� count_of_bytes == 2, �� ��� 2-�������� ������, � �.�. result.size = count_of_bytes; } break; } } return result; }