libsnobol4 1.0.2
High-performance SNOBOL4-style pattern matching library
Loading...
Searching...
No Matches
unicode_fold.h File Reference

Unicode case-folding lookup tables for libsnobol4. More...

#include <stdint.h>
#include "snobol/c23_compat.h"
Include dependency graph for unicode_fold.h:

Go to the source code of this file.

Functions

void snobol_to_upper_cp (uint32_t cp, uint32_t *out, int *out_len)
uint32_t snobol_to_lower_cp (uint32_t cp)

Detailed Description

Unicode case-folding lookup tables for libsnobol4.

Provides codepoint-level case conversion with no external ICU dependency. All data is compiled-in static C arrays.

Coverage:

  • U+0000–U+007F: ASCII fast path (arithmetic: ±32)
  • U+00C0–U+00FF: Latin-1 Supplement (UPPER_MAP[256] table)
  • U+0100–U+FFFF: Full Basic Multilingual Plane (generated pair tables, binary search)

Codepoints outside the BMP (U+10000+) are returned unchanged (identity mapping). Some lowercase codepoints expand to multiple uppercase codepoints; the best-known case is U+00DF (ß) → "SS" (U+0053 U+0053).

Definition in file unicode_fold.h.

Function Documentation

◆ snobol_to_lower_cp()

uint32_t snobol_to_lower_cp ( uint32_t cp)

Convert a Unicode codepoint to its lowercase equivalent.

Parameters
cpInput codepoint.
Returns
Lowercase codepoint, or cp itself if no mapping is found.

◆ snobol_to_upper_cp()

void snobol_to_upper_cp ( uint32_t cp,
uint32_t * out,
int * out_len )

Convert a Unicode codepoint to its uppercase equivalent(s).

Parameters
cpInput codepoint.
outCaller-provided output buffer of at least 2 uint32_t elements. On return, holds the resulting uppercase codepoint(s). The buffer is written by the function; ownership stays with the caller. Do NOT free the contents — they are scalar values.
out_lenSet to the number of codepoints written to out (1 or 2).