// 1. Count unique occurrences:

s64 count_ascii_codepoints[128] = {};
// s64 extended_codepoints[65536] = {};

Array<u32> unique_codepoints_utf32;

force_inline void unique_codepoints_utf32_add_unique (u32 unique) {
  array_add_if_unique(unique_codepoints_utf32, unique);
}

void count_unique_chars_from_string (string s) {
  string s_copy = s;
  
  while (s_copy.count > 0) {
    if (s_copy.data[0] == 0x5C) { // `\` character
      s_copy.data  += 1;
      s_copy.count -= 1;
    }
    u32 utf32_codepoint; s64 codepoint_source_length;
    bool success = character_utf8_to_utf32(s_copy.data, s_copy.count, &utf32_codepoint, &codepoint_source_length);
    
    if (success) {
      if (codepoint_source_length == 1) {
        Assert(utf32_codepoint <= 127);
          // Add to table
        count_ascii_codepoints[utf32_codepoint] += 1;
      } else {
        unique_codepoints_utf32_add_unique(utf32_codepoint);
        push_allocator(temp());
        string codepoint = copy_string(string_view(s_copy, 0, codepoint_source_length));
        log_todo("#TODO: keep track of unique codepoints. Codepoint: %s", codepoint);
      }
    }
    
    s_copy.data  += codepoint_source_length;
    s_copy.count -= codepoint_source_length;
  }
}

void count_unique_utf8_chars () { Timed_Block_Print("count_unique_utf8_chars");
  unique_codepoints_utf32.allocator = default_allocator();

  Assert(stfe != nullptr);
  for (s64 i = 0; i < stfe->dirs.offsets->count; i += 1) {
    string sample = get_file_string_view(stfe, i);

    count_unique_chars_from_string(sample);
  }
}
