# EAStdC

EAStdC is a package which implements a number of basic library facilities that are similar to those in the standard C library. This does not mean that its functionality is identical to the C standard library. It is an evolution and convergence of the rwstdc and UTFFoundation packages.

The fundamental design characteristics of EAStdC are:

- The package has minimal dependencies: EABase and EAAssert.
- It consists of simple standalone functions and classes.
- Memory is not allocated by any of the functions or classes, excepts possibly under pathological conditions.
- There is no thread-safety. All thread safety must be coordinated at a higher level by the user.
- It does not implement localization functionality. Localization functionality is left to specialized libraries for that purpose.
- With few exceptions, both char8_t and char16_t string functionality are supported equivalently.

### Should you use EAStdC functions that overlap with Standard C library functions?

A primary purpose of EAStdC is to provide a portable implementation of basic utility functions, many of which correspond the standard C library functions. Specifically:

- Provide a standardizes portable header file to #include.

- e.g. C libraries don’t use the same name for headers, such as malloc.h, sys/types.h, memory.h, etc.

- Provide standardized function names.

- e.g. EAStdC has Vsnprintf, as opposed to VC++ having _vsnprintf but GCC having vsnprintf.

- Provide standardized function implementations.

- e.g. Sprintf/Scanf work the same in EAStdC, unlike most C libraries.

- Provide faster versions.

- e.g. Faster strlen, memcpy, special fast memcpy versions. EAStdC sprintf is much faster than stdc.

- Provide versions that don’t exist in compiler-provided libraries.

- e.g. EAStdC has vsnprintf, whereas some C libraries don’t.

- Lower memory requirements.

- Some stdc functions tend to bring in a lot of object code, often because of their locale requirements.

- Provides consistent standardized encoding.

- EAStdC uses UTF8 for char8_t and UCS2 for char16_t, whereas C libraries aren’t consistent. wchar_t could be 8, 16, or 32 bit (we’ve seen each of these).

- Provide auxiliary or “better” versions of functions.

- e.g. EAStdC’s Random, DateTime.

- EAStdC has additional functionality that doesn’t directly match something from the Standard C library.

- e.g. Stopwatch, Hash, FixedPoint.

Primary downsides to EAStdC:

- It doesn’t have localization support. You can’t call setlocale() with it and have it change how it interprets “.” And “,” in numbers. You need to use the EALocale or EAText package for that, though EALocale and EAText do a better job than stdc does.
- EAStdC might have bugs that haven’t been eradicated, while most stdc implementations are pretty good.
- Stdc has better documentation, though the EAStdC functions that are stdc equivalents usually have the same specification.

In the case of overlap between stdc and EAStdC, I think the policy of what to use depends on your team conventions and your project requirements. Some notes:

- If you want to guarantee portability then you’re better off using EAStdC.
- Some functions (e.g. strlen and memcpy) are basic enough that the stdc versions are usually fine.

- Except EAStdC’s Strlen is faster than most stdc versions, and a surprising number of memcpy implementations for uncommon platforms are slow.

- If you think your code will need to build outside our codebase then maybe you should try to stick with stdc.