summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/src/UtfUtils.cc
blob: ae17aed77db5ade88241a7e59023460d157b9d49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* -------------------------------------------

  Copyright (C) 2025, Amlal El Mahrouss, all rights reserved.

------------------------------------------- */

#include <NeKit/Utils.h>

namespace Kernel {
Size urt_string_len(const Utf8Char* str) {
  SizeT len{0};

  while (str[len] != u8'\0') ++len;

  return len;
}

Void urt_set_memory(const voidPtr src, UInt32 dst, Size len) {
  Utf8Char* srcChr = reinterpret_cast<Utf8Char*>(src);
  Size      index  = 0;

  while (index < len) {
    srcChr[index] = dst;
    ++index;
  }
}

Int32 rt_string_cmp(const Utf8Char* src, const Utf8Char* cmp, Size size) {
  Int32 counter = 0;

  for (Size index = 0; index < size; ++index) {
    if (src[index] != cmp[index]) ++counter;
  }

  return counter;
}

Int urt_copy_memory(const VoidPtr src, VoidPtr dst, Size len) {
  Utf8Char* srcChr  = reinterpret_cast<Utf8Char*>(src);
  Utf8Char* dstChar = reinterpret_cast<Utf8Char*>(dst);

  Size index = 0;

  while (index < len) {
    dstChar[index] = srcChr[index];
    ++index;
  }

  return index;
}
}  // namespace Kernel