|
1 |
| -## UTF-8 String For C++ (utf8::ustring) |
| 1 | +## ⚙️ UTF-8 String For C++ (utf8::ustring) |
2 | 2 |
|
3 |
| -## Brief Description: |
4 |
| -This is an implementation of the UTF-8 encoding standard for C++, the implementation is based on the std::basic_string\<char\> class, this gives us the advantage of std::basic_string\<char\> class functions, as well as compatibility with some functions from the standard library. |
| 3 | +## 📜 Brief Description: |
| 4 | +This is an implementation of the `UTF-8` encoding standard for `C++`, the implementation is based on the `std::basic_string<char>` class, this gives us the advantage of `std::basic_string<char>` class functions, as well as compatibility with some functions from the standard library. |
5 | 5 |
|
6 |
| -## Code Style: |
7 |
| -- C++ AStyle code style was used for this project. |
| 6 | +## 📝 Code Style: |
| 7 | +- `C++ AStyle` code style was used for this project. |
8 | 8 |
|
9 |
| -## Technical Dependencies: |
10 |
| -- C++ 20 |
11 |
| -- CMake 3.14 |
| 9 | +## 🛠 Technical Dependencies: |
| 10 | +- `C++ 20` |
| 11 | +- `CMake 3.14` |
12 | 12 |
|
13 |
| -## Support Status On Systems: |
14 |
| -- [X] Linux |
15 |
| -- [ ] Windows (not yet verified) |
| 13 | +## 🔗 Support Status On Systems: |
| 14 | +- [X] Linux (verified on clang) |
| 15 | +- [X] Windows (verified on gcc && clang) |
16 | 16 |
|
17 |
| -## Library Features: |
| 17 | +## 💫 Library Features: |
18 | 18 | - Support for creating an object from: `std::string, std::string_view, const char*`
|
19 | 19 | - Comparing an `utf8::ustring` with `utf8::ustring` (comparison with `const char*`, `std::string`, `std::string_view` will be added in the future)
|
20 | 20 | - Copy/Move (<- assignment also) constructor implemented
|
21 | 21 | - O(1) Random Access
|
22 |
| -- Simple replacement of any character, e.g. a smaller character (1 byte) with a larger character (2-3-4 bytes). |
| 22 | +- Simple replacement of any character, e.g. a smaller character `(1 byte)` with a larger character `(2-3-4 bytes)`. |
23 | 23 |
|
24 |
| -## Performance Test: |
| 24 | +## ⚡️ Performance Test: |
25 | 25 | | String-Version | Test-Name | iteration count | time (for all iterations) |
|
26 | 26 | |:--------------:|:-----------------------:|:---------------:|:-------------------------:|
|
27 | 27 | | std::string | replace_char | 500'000 | ~0.57s |
|
28 | 28 | | utf8::ustring | replace_char | 500'000 | ~0.60s |
|
29 | 29 |
|
30 |
| -## Coming Soon: |
31 |
| -- A more detailed test and description of the string speed. |
32 |
| -- Test in Windows. |
33 |
| -- Introduction of new functions. |
34 |
| -- Code samples. |
| 30 | +## ❔ Replace Char O(1) ? |
| 31 | +Yes and no, in the case where we replace a character with another `with the same size`, we have `O(1)`, in the other case we have `O(~N)`, where N is the length of the string. |
| 32 | +But in any case we have `O(1) Random Access`. |
35 | 33 |
|
36 |
| - <div style="text-align: center;"> |
37 |
| - © 2024 Andrii (AKA b1tflyyyy). All rights reserved. |
38 |
| - </div> |
| 34 | +## 📚 Code Samples: |
| 35 | +```cpp |
| 36 | +std::string str{ "hello world!" }; |
| 37 | +utf8::ustring ustr{ str }; |
| 38 | + |
| 39 | +ustr.replace_char("п", 0); // "пello world!" |
| 40 | + |
| 41 | +ustr == "hi !"; // false |
| 42 | +ustr == str; // false |
| 43 | +``` |
| 44 | +
|
| 45 | +## ⭐️ Coming Soon: |
| 46 | +- Write/read to file. |
| 47 | +- Add new features. |
| 48 | +- Docs. |
| 49 | +
|
| 50 | +### © 2024 Andrii (AKA b1tflyyyy). All rights reserved. |
0 commit comments