ToyGine2 26.2.0
Game Engine for retro consoles
Loading...
Searching...
No Matches
utils.hpp File Reference

Core utilities: encoding conversion, string metrics, and number formatting. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  toy
 Root namespace containing all engine modules.

Functions

wchar_t * toy::utf8toWChar (wchar_t *dest, size_t destSize, const char *src, size_t count) noexcept
 Converts a UTF-8 C string to a wide-character string with a character count limit.
constexpr wchar_t * toy::utf8toWChar (wchar_t *dest, size_t destSize, const char *src) noexcept
 Converts a UTF-8 C string to a wide-character string (full source length).
template<StringLike T>
constexpr wchar_t * toy::utf8toWChar (wchar_t *dest, size_t destSize, const T &src) noexcept
 Converts a UTF-8 toy::StringLike object to a wide-character string.
char * toy::wcharToUtf8 (char *dest, size_t destSize, const wchar_t *src) noexcept
 Converts a wide-character C string to UTF-8.
size_t toy::utf8Len (const char *string) noexcept
 Returns the number of Unicode code points in a UTF-8 encoded C string.
constexpr char * toy::reverseString (char *str, size_t count=0) noexcept
 Reverses a C string in-place.
template<std::signed_integral T>
constexpr char * toy::itoa (char *dest, size_t destSize, T value) noexcept
 Converts a signed integer to its decimal C string representation.
template<std::unsigned_integral T>
constexpr char * toy::utoa (char *dest, size_t destSize, T value, unsigned base=10) noexcept
 Converts an unsigned integer to its C string representation in the given base.
char * toy::ftoa (char *dest, size_t destSize, float value, size_t precision=7) noexcept
 Converts a float to its decimal C string representation with specified precision.
char * toy::ftoa (char *dest, size_t destSize, double value, size_t precision=15) noexcept
 Converts a double to its decimal C string representation with specified precision.
void toy::formatNumberString (char *buffer, size_t bufferSize, const char *separator) noexcept
 Inserts a grouping separator into a number C string every three digits from the right.
size_t toy::highestBit (uint64_t value) noexcept
 Returns the 0-based index of the highest set bit in value.

Variables

constexpr size_t toy::WCHAR_IN_UTF8_MAX_SIZE = 3
 Maximum UTF-8 byte length for one BMP character.

Detailed Description

Core utilities: encoding conversion, string metrics, and number formatting.

Declares utf8toWChar, wcharToUtf8, utf8Len, reverseString, itoa, utoa, ftoa, formatNumberString, highestBit, and related free functions in namespace toy. Non-inline definitions live in utils.cpp; callers supply buffers. No dynamic allocation in these APIs.

Note
Included by core.hpp; do not include this file directly.