This repository has been archived on 2026-11-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
my-first-apex-internal/inc/shd/stl_uni.h
T
2026-11-05 02:19:09 +01:00

59 lines
1.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#pragma warning(push)
#pragma warning(disable : 4244 4066 4309 4305 4244)
namespace stl
{
inline_block char wtoc(wchar_t w)
{
if (w == L'Ё') return 'Ё';
if (w == L'ё') return 'ё';
if (w >= L'А' && w <= L'Я') return w - L'А' + 'А';
if (w >= L'а' && w <= L'я') return w - L'а' + 'а';
return (char)w;
}
inline_block wchar_t ctow(char w)
{
if (w == 'Ё') return L'Ё';
if (w == 'ё') return L'ё';
if (w >= 'А' && w <= 'Я') return w - 'А' + L'А';
if (w >= 'а' && w <= 'я') return w - 'а' + L'а';
return w;
}
inline_block int mbstowcs(wchar_t* Dest, const char* Source, unsigned __int64 Length, unsigned __int64 MaxCount)
{
int result = -1;
if (!Dest)
return 0;
if (Dest && !MaxCount)
return 0;
if (MaxCount > 0x7FFFFFFF)
return -1;
if (!Length)
{
Length = strlen(Source);
if (!Length)
return -1;
}
for (result = 0; (result < Length && result < MaxCount); result++)
{
Dest[result] = ctow(Source[result]);
}
return result;
}
}
#pragma warning(pop)