# EAScanf

## Introduction

EAScanf provides a portable version of the C scanf family of functions which improves on the C family in the following ways:

- Behaves identically on all platforms
- Provides the full gamut of scanf functions, including vsscanf
- Is more efficient
- Never allocates memory
- Provides both 8 and 16 bit versions for all platforms
- Provides useful extended functionality
- Complies with the C99 standard (except for the %a format, as of this writing)
- Is readable enough to be traced/debugged by non-experts
- Is savvy to UTF8 Unicode

The primary disadvantages of EAScanf are:

- It doesn't use locale-specific formatting
- It isn't part of the C/C++ standard library

EAScanf doesn't attempt to solve the locale formatting problem because users really are better off using serious locale libraries for such things rather than using the meager support provided by the C standard library. The EALocale library attempts to provide such functionality.

EAScanf provides the following functions in 8 and 16 bit versions:

    int Cscanf(ReadFunction8 pReadFunction8, void* pContext, const char8_t* pFormat, ...);
    int Fscanf(FILE* pFile, const char8_t* pFormat, ...);
    int Scanf(const char8_t* pFormat, ...);
    int Sscanf(const char8_t*  pTextBuffer, const char8_t* pFormat, ...);

    int Cscanf(ReadFunction16 pReadFunction16, void* pContext, const char16_t* pFormat, ...);
    int Fscanf(FILE* pFile, const char16_t* pFormat, ...);
    int Scanf(const char16_t* pFormat, ...);
    int Sscanf(const char16_t* pTextBuffer, const char16_t* pFormat, ...);

    int Vcscanf(ReadFunction8 pReadFunction8, void* pContext, const char8_t* pFormat, va_list arguments);
    int Vfscanf(FILE* pFile, const char8_t* pFormat, va_list arguments);
    int Vscanf(const char8_t* pFormat, va_list arguments);
    int Vsscanf(const char8_t* pTextBuffer, const char8_t* pFormat, va_list arguments);

    int Vcscanf(ReadFunction16 pReadFunction16, void* pContext, const char16_t* pFormat, va_list arguments);
    int Vfscanf(FILE* pFile, const char16_t* pFormat, va_list arguments);
    int Vscanf(const char16_t* pFormat, va_list arguments);
    int Vsscanf(const char16_t* pTextBuffer, const char16_t* pFormat, va_list arguments);

## Extended Functionality

EAPrintf provides extended format functionality not found in the C99 standard but which is useful nevertheless:

Format | Description | Example | Example output
b | Binary output field type (joins d, i, x, o, etc.). | sscanf("11111111", "%b", &integer); | integer == 0xff
I8 | 8 bit integer field modifier. | sscanf("0xff", "%I8d", &int8); | int8 == 0xff
I16 | 16 bit integer field modifier. | sscanf("0xffff", "%I16u", &uint16); | uint16 == 0xffff
I32 | 32 bit integer field modifier. | sscanf("0xffffffff", "%I32d", &int32); | int32 == 0xffffffff
I64 | 64 bit integer field modifier. | sscanf("0xffffffffffffffff", "%I64u", &int64); | int64 == -1
I128 | 128 bit integer field modifier. | sscanf("0xffffffffffffffffffffffffffffffff", "%I128d", &int128); | int128 = -1

## Example usage

To do.