Initial commit

Signed-off-by: sisungo <[email protected]>
This commit is contained in:
sisungo committed 2026-11-20 10:24:59 +00:00
commit 0cc87ce05e
12 files changed
+8860

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
*.so
*.o
+168
View File
@@ -0,0 +1,168 @@
/*
* libSemiOSCharsetCP850.so
* SemiOS charset library: CP850 (IBM PC code page 850)
*/
#include <stdint.h>
#include <stddef.h>
#define SEMIOS_EXPORT __attribute__((visibility("default")))
/* Unicode mappings for bytes 0x80..0xFF. */
static const uint16_t cp850_high[128] = {
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE,
0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0,
};
SEMIOS_EXPORT
int SemiOS_Charset_CP850_ToUTF8(
char **restrict in, size_t *restrict inb,
char **restrict out, size_t *restrict outb
) {
while (*inb > 0) {
unsigned char b = (unsigned char)**in;
uint32_t cp = b < 0x80u ? (uint32_t)b : cp850_high[b - 0x80u];
/* Determine UTF-8 length. */
size_t n;
if (cp < 0x80u) n = 1;
else if (cp < 0x800u) n = 2;
else if (cp < 0x10000u) n = 3;
else n = 4;
if (*outb < n) {
return -1;
}
/* Encode into UTF-8. */
unsigned char *o = (unsigned char *)*out;
if (n == 1) {
o[0] = (unsigned char)cp;
} else if (n == 2) {
o[0] = (unsigned char)(0xC0u | (cp >> 6));
o[1] = (unsigned char)(0x80u | (cp & 0x3Fu));
} else if (n == 3) {
o[0] = (unsigned char)(0xE0u | (cp >> 12));
o[1] = (unsigned char)(0x80u | ((cp >> 6) & 0x3Fu));
o[2] = (unsigned char)(0x80u | (cp & 0x3Fu));
} else {
o[0] = (unsigned char)(0xF0u | (cp >> 18));
o[1] = (unsigned char)(0x80u | ((cp >> 12) & 0x3Fu));
o[2] = (unsigned char)(0x80u | ((cp >> 6) & 0x3Fu));
o[3] = (unsigned char)(0x80u | (cp & 0x3Fu));
}
*in += 1;
*inb -= 1;
*out += n;
*outb -= n;
}
return 0;
}
SEMIOS_EXPORT
int SemiOS_Charset_CP850_FromUTF8(
char **restrict in, size_t *restrict inb,
char **restrict out, size_t *restrict outb
) {
while (*inb > 0) {
const unsigned char *p = (const unsigned char *)*in;
unsigned char b0 = p[0];
uint32_t cp;
size_t n;
if (b0 < 0x80u) {
/* ASCII */
cp = b0;
n = 1;
} else if ((b0 & 0xE0u) == 0xC0u) {
/* 2-byte sequence */
if (*inb < 2) return -1;
unsigned char b1 = p[1];
if ((b1 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x1Fu) << 6)
| (uint32_t)(b1 & 0x3Fu);
if (cp < 0x80u) return -2; /* overlong */
if (cp >= 0xD800u && cp <= 0xDFFFu) return -2; /* surrogate */
n = 2;
} else if ((b0 & 0xF0u) == 0xE0u) {
/* 3-byte sequence */
if (*inb < 3) return -1;
unsigned char b1 = p[1];
unsigned char b2 = p[2];
if ((b1 & 0xC0u) != 0x80u || (b2 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x0Fu) << 12)
| ((uint32_t)(b1 & 0x3Fu) << 6)
| (uint32_t)(b2 & 0x3Fu);
if (cp < 0x800u) return -2; /* overlong */
if (cp >= 0xD800u && cp <= 0xDFFFu) return -2; /* surrogate */
n = 3;
} else if ((b0 & 0xF8u) == 0xF0u) {
/* 4-byte sequence */
if (*inb < 4) return -1;
unsigned char b1 = p[1];
unsigned char b2 = p[2];
unsigned char b3 = p[3];
if ((b1 & 0xC0u) != 0x80u ||
(b2 & 0xC0u) != 0x80u ||
(b3 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x07u) << 18)
| ((uint32_t)(b1 & 0x3Fu) << 12)
| ((uint32_t)(b2 & 0x3Fu) << 6)
| (uint32_t)(b3 & 0x3Fu);
if (cp < 0x10000u) return -2; /* overlong */
if (cp > 0x10FFFFu) return -2; /* out of range */
n = 4;
} else {
return -2; /* invalid lead */
}
/* Map the code point back to a CP850 byte. */
unsigned char b;
if (cp < 0x80u) {
b = (unsigned char)cp;
} else {
size_t i;
for (i = 0; i < 128; i++) {
if (cp850_high[i] == cp) break;
}
if (i == 128) {
return -2; /* unmappable */
}
b = (unsigned char)(0x80u + i);
}
if (*outb < 1) {
return -1;
}
**out = (char)b;
*in += n;
*inb -= n;
*out += 1;
*outb -= 1;
}
return 0;
}
+7482
View File
File diff suppressed because it is too large. Load diff
+24
View File
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <https://unlicense.org/>
+236
View File
@@ -0,0 +1,236 @@
/*
* libSemiOSCharsetUTF-16.so
* SemiOS charset library: UTF-16 (native-endian, with BOM)
*/
#include <stdint.h>
#include <stddef.h>
#define SEMIOS_EXPORT __attribute__((visibility("default")))
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define UTF16_NATIVE_BIG_ENDIAN 1
#elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define UTF16_NATIVE_BIG_ENDIAN 0
#else
#error "Unable to determine native byte order"
#endif
static uint32_t utf16_decode(const unsigned char *p, int big_endian) {
if (big_endian) {
return ((uint32_t)p[0] << 8) | (uint32_t)p[1];
}
return (uint32_t)p[0] | ((uint32_t)p[1] << 8);
}
static void utf16_encode(unsigned char *o, uint32_t u, int big_endian) {
if (big_endian) {
o[0] = (unsigned char)((u >> 8) & 0xFFu);
o[1] = (unsigned char)( u & 0xFFu);
} else {
o[0] = (unsigned char)( u & 0xFFu);
o[1] = (unsigned char)((u >> 8) & 0xFFu);
}
}
SEMIOS_EXPORT
int SemiOS_Charset_UTF_16_ToUTF8(
char **restrict in, size_t *restrict inb,
char **restrict out, size_t *restrict outb
) {
int big_endian = UTF16_NATIVE_BIG_ENDIAN;
/* Strip an optional BOM and let it select the byte order. */
if (*inb >= 2) {
const unsigned char *p = (const unsigned char *)*in;
uint32_t mark = utf16_decode(p, 1); /* BOMs are byte-swapped U+FEFF */
if (mark == 0xFEFFu) {
big_endian = 1;
*in += 2;
*inb -= 2;
} else if (mark == 0xFFFEu) {
big_endian = 0;
*in += 2;
*inb -= 2;
}
}
while (*inb >= 2) {
const unsigned char *p = (const unsigned char *)*in;
/* Decode 16-bit code unit in the selected byte order. */
uint32_t u = utf16_decode(p, big_endian);
uint32_t cp;
size_t consumed;
if (u >= 0xD800u && u <= 0xDBFFu) {
/* High surrogate: must be followed by a low surrogate. */
if (*inb < 4) {
return -1;
}
uint32_t lo = utf16_decode(p + 2, big_endian);
if (lo < 0xDC00u || lo > 0xDFFFu) {
return -2;
}
cp = 0x10000u
+ ((u - 0xD800u) << 10)
+ (lo - 0xDC00u);
consumed = 4;
} else if (u >= 0xDC00u && u <= 0xDFFFu) {
/* Unpaired low surrogate. */
return -2;
} else {
cp = u;
consumed = 2;
}
/* Determine UTF-8 length. */
size_t n;
if (cp < 0x80u) n = 1;
else if (cp < 0x800u) n = 2;
else if (cp < 0x10000u) n = 3;
else n = 4;
if (*outb < n) {
return -1;
}
/* Encode into UTF-8. */
unsigned char *o = (unsigned char *)*out;
if (n == 1) {
o[0] = (unsigned char)cp;
} else if (n == 2) {
o[0] = (unsigned char)(0xC0u | (cp >> 6));
o[1] = (unsigned char)(0x80u | (cp & 0x3Fu));
} else if (n == 3) {
o[0] = (unsigned char)(0xE0u | (cp >> 12));
o[1] = (unsigned char)(0x80u | ((cp >> 6) & 0x3Fu));
o[2] = (unsigned char)(0x80u | (cp & 0x3Fu));
} else {
o[0] = (unsigned char)(0xF0u | (cp >> 18));
o[1] = (unsigned char)(0x80u | ((cp >> 12) & 0x3Fu));
o[2] = (unsigned char)(0x80u | ((cp >> 6) & 0x3Fu));
o[3] = (unsigned char)(0x80u | (cp & 0x3Fu));
}
*in += consumed;
*inb -= consumed;
*out += n;
*outb -= n;
}
/* If any input remains, it is a partial 16-bit unit. */
return *inb == 0 ? 0 : -1;
}
SEMIOS_EXPORT
int SemiOS_Charset_UTF_16_FromUTF8(
char **restrict in, size_t *restrict inb,
char **restrict out, size_t *restrict outb
) {
int wrote_bom = 0;
while (*inb > 0) {
const unsigned char *p = (const unsigned char *)*in;
unsigned char b0 = p[0];
uint32_t cp;
size_t n;
if (b0 < 0x80u) {
/* ASCII */
cp = b0;
n = 1;
} else if ((b0 & 0xE0u) == 0xC0u) {
/* 2-byte sequence */
if (*inb < 2) return -1;
unsigned char b1 = p[1];
if ((b1 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x1Fu) << 6)
| (uint32_t)(b1 & 0x3Fu);
if (cp < 0x80u) return -2; /* overlong */
if (cp >= 0xD800u && cp <= 0xDFFFu) return -2; /* surrogate */
n = 2;
} else if ((b0 & 0xF0u) == 0xE0u) {
/* 3-byte sequence */
if (*inb < 3) return -1;
unsigned char b1 = p[1];
unsigned char b2 = p[2];
if ((b1 & 0xC0u) != 0x80u || (b2 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x0Fu) << 12)
| ((uint32_t)(b1 & 0x3Fu) << 6)
| (uint32_t)(b2 & 0x3Fu);
if (cp < 0x800u) return -2; /* overlong */
if (cp >= 0xD800u && cp <= 0xDFFFu) return -2; /* surrogate */
n = 3;
} else if ((b0 & 0xF8u) == 0xF0u) {
/* 4-byte sequence */
if (*inb < 4) return -1;
unsigned char b1 = p[1];
unsigned char b2 = p[2];
unsigned char b3 = p[3];
if ((b1 & 0xC0u) != 0x80u ||
(b2 & 0xC0u) != 0x80u ||
(b3 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x07u) << 18)
| ((uint32_t)(b1 & 0x3Fu) << 12)
| ((uint32_t)(b2 & 0x3Fu) << 6)
| (uint32_t)(b3 & 0x3Fu);
if (cp < 0x10000u) return -2; /* overlong */
if (cp > 0x10FFFFu) return -2; /* out of range */
n = 4;
} else {
return -2; /* invalid lead */
}
size_t need = (wrote_bom ? 0 : 2) + (cp >= 0x10000u ? 4 : 2);
if (*outb < need) {
return -1;
}
unsigned char *o = (unsigned char *)*out;
/* Emit the native-endian BOM before the first character. */
if (!wrote_bom) {
utf16_encode(o, 0xFEFFu, UTF16_NATIVE_BIG_ENDIAN);
o += 2;
*out += 2;
*outb -= 2;
wrote_bom = 1;
}
if (cp >= 0x10000u) {
/* Supplementary code point: encode as a surrogate pair. */
uint32_t v = cp - 0x10000u;
uint32_t hi = 0xD800u + (v >> 10);
uint32_t lo = 0xDC00u + (v & 0x3FFu);
utf16_encode(o, hi, UTF16_NATIVE_BIG_ENDIAN);
utf16_encode(o + 2, lo, UTF16_NATIVE_BIG_ENDIAN);
*out += 4;
*outb -= 4;
} else {
/* BMP code point: encode as a single 16-bit unit. */
utf16_encode(o, cp, UTF16_NATIVE_BIG_ENDIAN);
*out += 2;
*outb -= 2;
}
*in += n;
*inb -= n;
}
return 0;
}
+186
View File
@@ -0,0 +1,186 @@
/*
* libSemiOSCharsetUTF-16BE.so
* SemiOS charset library: UTF-16BE (big-endian, no BOM)
*/
#include <stdint.h>
#include <stddef.h>
#define SEMIOS_EXPORT __attribute__((visibility("default")))
SEMIOS_EXPORT
int SemiOS_Charset_UTF_16BE_ToUTF8(
char **restrict in, size_t *restrict inb,
char **restrict out, size_t *restrict outb
) {
while (*inb >= 2) {
const unsigned char *p = (const unsigned char *)*in;
/* Decode big-endian 16-bit code unit. */
uint32_t u = ((uint32_t)p[0] << 8) | (uint32_t)p[1];
uint32_t cp;
size_t consumed;
if (u >= 0xD800u && u <= 0xDBFFu) {
/* High surrogate: must be followed by a low surrogate. */
if (*inb < 4) {
return -1;
}
uint32_t lo = ((uint32_t)p[2] << 8) | (uint32_t)p[3];
if (lo < 0xDC00u || lo > 0xDFFFu) {
return -2;
}
cp = 0x10000u
+ ((u - 0xD800u) << 10)
+ (lo - 0xDC00u);
consumed = 4;
} else if (u >= 0xDC00u && u <= 0xDFFFu) {
/* Unpaired low surrogate. */
return -2;
} else {
cp = u;
consumed = 2;
}
/* Determine UTF-8 length. */
size_t n;
if (cp < 0x80u) n = 1;
else if (cp < 0x800u) n = 2;
else if (cp < 0x10000u) n = 3;
else n = 4;
if (*outb < n) {
return -1;
}
/* Encode into UTF-8. */
unsigned char *o = (unsigned char *)*out;
if (n == 1) {
o[0] = (unsigned char)cp;
} else if (n == 2) {
o[0] = (unsigned char)(0xC0u | (cp >> 6));
o[1] = (unsigned char)(0x80u | (cp & 0x3Fu));
} else if (n == 3) {
o[0] = (unsigned char)(0xE0u | (cp >> 12));
o[1] = (unsigned char)(0x80u | ((cp >> 6) & 0x3Fu));
o[2] = (unsigned char)(0x80u | (cp & 0x3Fu));
} else {
o[0] = (unsigned char)(0xF0u | (cp >> 18));
o[1] = (unsigned char)(0x80u | ((cp >> 12) & 0x3Fu));
o[2] = (unsigned char)(0x80u | ((cp >> 6) & 0x3Fu));
o[3] = (unsigned char)(0x80u | (cp & 0x3Fu));
}
*in += consumed;
*inb -= consumed;
*out += n;
*outb -= n;
}
/* If any input remains, it is a partial 16-bit unit. */
return *inb == 0 ? 0 : -1;
}
SEMIOS_EXPORT
int SemiOS_Charset_UTF_16BE_FromUTF8(
char **restrict in, size_t *restrict inb,
char **restrict out, size_t *restrict outb
) {
while (*inb > 0) {
const unsigned char *p = (const unsigned char *)*in;
unsigned char b0 = p[0];
uint32_t cp;
size_t n;
if (b0 < 0x80u) {
/* ASCII */
cp = b0;
n = 1;
} else if ((b0 & 0xE0u) == 0xC0u) {
/* 2-byte sequence */
if (*inb < 2) return -1;
unsigned char b1 = p[1];
if ((b1 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x1Fu) << 6)
| (uint32_t)(b1 & 0x3Fu);
if (cp < 0x80u) return -2; /* overlong */
if (cp >= 0xD800u && cp <= 0xDFFFu) return -2; /* surrogate */
n = 2;
} else if ((b0 & 0xF0u) == 0xE0u) {
/* 3-byte sequence */
if (*inb < 3) return -1;
unsigned char b1 = p[1];
unsigned char b2 = p[2];
if ((b1 & 0xC0u) != 0x80u || (b2 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x0Fu) << 12)
| ((uint32_t)(b1 & 0x3Fu) << 6)
| (uint32_t)(b2 & 0x3Fu);
if (cp < 0x800u) return -2; /* overlong */
if (cp >= 0xD800u && cp <= 0xDFFFu) return -2; /* surrogate */
n = 3;
} else if ((b0 & 0xF8u) == 0xF0u) {
/* 4-byte sequence */
if (*inb < 4) return -1;
unsigned char b1 = p[1];
unsigned char b2 = p[2];
unsigned char b3 = p[3];
if ((b1 & 0xC0u) != 0x80u ||
(b2 & 0xC0u) != 0x80u ||
(b3 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x07u) << 18)
| ((uint32_t)(b1 & 0x3Fu) << 12)
| ((uint32_t)(b2 & 0x3Fu) << 6)
| (uint32_t)(b3 & 0x3Fu);
if (cp < 0x10000u) return -2; /* overlong */
if (cp > 0x10FFFFu) return -2; /* out of range */
n = 4;
} else {
return -2; /* invalid lead */
}
if (cp >= 0x10000u) {
/* Supplementary code point: encode as a surrogate pair. */
if (*outb < 4) {
return -1;
}
uint32_t v = cp - 0x10000u;
uint32_t hi = 0xD800u + (v >> 10);
uint32_t lo = 0xDC00u + (v & 0x3FFu);
unsigned char *o = (unsigned char *)*out;
o[0] = (unsigned char)((hi >> 8) & 0xFFu);
o[1] = (unsigned char)( hi & 0xFFu);
o[2] = (unsigned char)((lo >> 8) & 0xFFu);
o[3] = (unsigned char)( lo & 0xFFu);
*out += 4;
*outb -= 4;
} else {
/* BMP code point: encode as a single 16-bit unit. */
if (*outb < 2) {
return -1;
}
unsigned char *o = (unsigned char *)*out;
o[0] = (unsigned char)((cp >> 8) & 0xFFu);
o[1] = (unsigned char)( cp & 0xFFu);
*out += 2;
*outb -= 2;
}
*in += n;
*inb -= n;
}
return 0;
}
+186
View File
@@ -0,0 +1,186 @@
/*
* libSemiOSCharsetUTF-16LE.so
* SemiOS charset library: UTF-16LE (little-endian, no BOM)
*/
#include <stdint.h>
#include <stddef.h>
#define SEMIOS_EXPORT __attribute__((visibility("default")))
SEMIOS_EXPORT
int SemiOS_Charset_UTF_16LE_ToUTF8(
char **restrict in, size_t *restrict inb,
char **restrict out, size_t *restrict outb
) {
while (*inb >= 2) {
const unsigned char *p = (const unsigned char *)*in;
/* Decode little-endian 16-bit code unit. */
uint32_t u = (uint32_t)p[0] | ((uint32_t)p[1] << 8);
uint32_t cp;
size_t consumed;
if (u >= 0xD800u && u <= 0xDBFFu) {
/* High surrogate: must be followed by a low surrogate. */
if (*inb < 4) {
return -1;
}
uint32_t lo = (uint32_t)p[2] | ((uint32_t)p[3] << 8);
if (lo < 0xDC00u || lo > 0xDFFFu) {
return -2;
}
cp = 0x10000u
+ ((u - 0xD800u) << 10)
+ (lo - 0xDC00u);
consumed = 4;
} else if (u >= 0xDC00u && u <= 0xDFFFu) {
/* Unpaired low surrogate. */
return -2;
} else {
cp = u;
consumed = 2;
}
/* Determine UTF-8 length. */
size_t n;
if (cp < 0x80u) n = 1;
else if (cp < 0x800u) n = 2;
else if (cp < 0x10000u) n = 3;
else n = 4;
if (*outb < n) {
return -1;
}
/* Encode into UTF-8. */
unsigned char *o = (unsigned char *)*out;
if (n == 1) {
o[0] = (unsigned char)cp;
} else if (n == 2) {
o[0] = (unsigned char)(0xC0u | (cp >> 6));
o[1] = (unsigned char)(0x80u | (cp & 0x3Fu));
} else if (n == 3) {
o[0] = (unsigned char)(0xE0u | (cp >> 12));
o[1] = (unsigned char)(0x80u | ((cp >> 6) & 0x3Fu));
o[2] = (unsigned char)(0x80u | (cp & 0x3Fu));
} else {
o[0] = (unsigned char)(0xF0u | (cp >> 18));
o[1] = (unsigned char)(0x80u | ((cp >> 12) & 0x3Fu));
o[2] = (unsigned char)(0x80u | ((cp >> 6) & 0x3Fu));
o[3] = (unsigned char)(0x80u | (cp & 0x3Fu));
}
*in += consumed;
*inb -= consumed;
*out += n;
*outb -= n;
}
/* If any input remains, it is a partial 16-bit unit. */
return *inb == 0 ? 0 : -1;
}
SEMIOS_EXPORT
int SemiOS_Charset_UTF_16LE_FromUTF8(
char **restrict in, size_t *restrict inb,
char **restrict out, size_t *restrict outb
) {
while (*inb > 0) {
const unsigned char *p = (const unsigned char *)*in;
unsigned char b0 = p[0];
uint32_t cp;
size_t n;
if (b0 < 0x80u) {
/* ASCII */
cp = b0;
n = 1;
} else if ((b0 & 0xE0u) == 0xC0u) {
/* 2-byte sequence */
if (*inb < 2) return -1;
unsigned char b1 = p[1];
if ((b1 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x1Fu) << 6)
| (uint32_t)(b1 & 0x3Fu);
if (cp < 0x80u) return -2; /* overlong */
if (cp >= 0xD800u && cp <= 0xDFFFu) return -2; /* surrogate */
n = 2;
} else if ((b0 & 0xF0u) == 0xE0u) {
/* 3-byte sequence */
if (*inb < 3) return -1;
unsigned char b1 = p[1];
unsigned char b2 = p[2];
if ((b1 & 0xC0u) != 0x80u || (b2 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x0Fu) << 12)
| ((uint32_t)(b1 & 0x3Fu) << 6)
| (uint32_t)(b2 & 0x3Fu);
if (cp < 0x800u) return -2; /* overlong */
if (cp >= 0xD800u && cp <= 0xDFFFu) return -2; /* surrogate */
n = 3;
} else if ((b0 & 0xF8u) == 0xF0u) {
/* 4-byte sequence */
if (*inb < 4) return -1;
unsigned char b1 = p[1];
unsigned char b2 = p[2];
unsigned char b3 = p[3];
if ((b1 & 0xC0u) != 0x80u ||
(b2 & 0xC0u) != 0x80u ||
(b3 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x07u) << 18)
| ((uint32_t)(b1 & 0x3Fu) << 12)
| ((uint32_t)(b2 & 0x3Fu) << 6)
| (uint32_t)(b3 & 0x3Fu);
if (cp < 0x10000u) return -2; /* overlong */
if (cp > 0x10FFFFu) return -2; /* out of range */
n = 4;
} else {
return -2; /* invalid lead */
}
if (cp >= 0x10000u) {
/* Supplementary code point: encode as a surrogate pair. */
if (*outb < 4) {
return -1;
}
uint32_t v = cp - 0x10000u;
uint32_t hi = 0xD800u + (v >> 10);
uint32_t lo = 0xDC00u + (v & 0x3FFu);
unsigned char *o = (unsigned char *)*out;
o[0] = (unsigned char)( hi & 0xFFu);
o[1] = (unsigned char)((hi >> 8) & 0xFFu);
o[2] = (unsigned char)( lo & 0xFFu);
o[3] = (unsigned char)((lo >> 8) & 0xFFu);
*out += 4;
*outb -= 4;
} else {
/* BMP code point: encode as a single 16-bit unit. */
if (*outb < 2) {
return -1;
}
unsigned char *o = (unsigned char *)*out;
o[0] = (unsigned char)( cp & 0xFFu);
o[1] = (unsigned char)((cp >> 8) & 0xFFu);
*out += 2;
*outb -= 2;
}
*in += n;
*inb -= n;
}
return 0;
}
+211
View File
@@ -0,0 +1,211 @@
/*
* libSemiOSCharsetUTF-32.so
* SemiOS charset library: UTF-32 (native-endian, with BOM)
*/
#include <stdint.h>
#include <stddef.h>
#define SEMIOS_EXPORT __attribute__((visibility("default")))
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define UTF32_NATIVE_BIG_ENDIAN 1
#elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define UTF32_NATIVE_BIG_ENDIAN 0
#else
#error "Unable to determine native byte order"
#endif
static uint32_t utf32_decode(const unsigned char *p, int big_endian) {
if (big_endian) {
return ((uint32_t)p[0] << 24)
| ((uint32_t)p[1] << 16)
| ((uint32_t)p[2] << 8)
| (uint32_t)p[3];
}
return (uint32_t)p[0]
| ((uint32_t)p[1] << 8)
| ((uint32_t)p[2] << 16)
| ((uint32_t)p[3] << 24);
}
static void utf32_encode(unsigned char *o, uint32_t cp, int big_endian) {
if (big_endian) {
o[0] = (unsigned char)((cp >> 24) & 0xFFu);
o[1] = (unsigned char)((cp >> 16) & 0xFFu);
o[2] = (unsigned char)((cp >> 8) & 0xFFu);
o[3] = (unsigned char)( cp & 0xFFu);
} else {
o[0] = (unsigned char)( cp & 0xFFu);
o[1] = (unsigned char)((cp >> 8) & 0xFFu);
o[2] = (unsigned char)((cp >> 16) & 0xFFu);
o[3] = (unsigned char)((cp >> 24) & 0xFFu);
}
}
SEMIOS_EXPORT
int SemiOS_Charset_UTF_32_ToUTF8(
char **restrict in, size_t *restrict inb,
char **restrict out, size_t *restrict outb
) {
int big_endian = UTF32_NATIVE_BIG_ENDIAN;
/* Strip an optional BOM and let it select the byte order. */
if (*inb >= 4) {
const unsigned char *p = (const unsigned char *)*in;
uint32_t mark = utf32_decode(p, 1); /* BOMs are byte-swapped U+FEFF */
if (mark == 0x0000FEFFu) {
big_endian = 1;
*in += 4;
*inb -= 4;
} else if (mark == 0xFFFE0000u) {
big_endian = 0;
*in += 4;
*inb -= 4;
}
}
while (*inb >= 4) {
const unsigned char *p = (const unsigned char *)*in;
/* Decode 32-bit code unit in the selected byte order. */
uint32_t cp = utf32_decode(p, big_endian);
/* Reject surrogates and out-of-Unicode-range values. */
if (cp > 0x10FFFFu || (cp >= 0xD800u && cp <= 0xDFFFu)) {
return -2;
}
/* Determine UTF-8 length. */
size_t n;
if (cp < 0x80u) n = 1;
else if (cp < 0x800u) n = 2;
else if (cp < 0x10000u) n = 3;
else n = 4;
if (*outb < n) {
return -1;
}
/* Encode into UTF-8. */
unsigned char *o = (unsigned char *)*out;
if (n == 1) {
o[0] = (unsigned char)cp;
} else if (n == 2) {
o[0] = (unsigned char)(0xC0u | (cp >> 6));
o[1] = (unsigned char)(0x80u | (cp & 0x3Fu));
} else if (n == 3) {
o[0] = (unsigned char)(0xE0u | (cp >> 12));
o[1] = (unsigned char)(0x80u | ((cp >> 6) & 0x3Fu));
o[2] = (unsigned char)(0x80u | (cp & 0x3Fu));
} else {
o[0] = (unsigned char)(0xF0u | (cp >> 18));
o[1] = (unsigned char)(0x80u | ((cp >> 12) & 0x3Fu));
o[2] = (unsigned char)(0x80u | ((cp >> 6) & 0x3Fu));
o[3] = (unsigned char)(0x80u | (cp & 0x3Fu));
}
*in += 4;
*inb -= 4;
*out += n;
*outb -= n;
}
/* If any input remains, it is a partial 32-bit unit. */
return *inb == 0 ? 0 : -1;
}
SEMIOS_EXPORT
int SemiOS_Charset_UTF_32_FromUTF8(
char **restrict in, size_t *restrict inb,
char **restrict out, size_t *restrict outb
) {
int wrote_bom = 0;
while (*inb > 0) {
const unsigned char *p = (const unsigned char *)*in;
unsigned char b0 = p[0];
uint32_t cp;
size_t n;
if (b0 < 0x80u) {
/* ASCII */
cp = b0;
n = 1;
} else if ((b0 & 0xE0u) == 0xC0u) {
/* 2-byte sequence */
if (*inb < 2) return -1;
unsigned char b1 = p[1];
if ((b1 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x1Fu) << 6)
| (uint32_t)(b1 & 0x3Fu);
if (cp < 0x80u) return -2; /* overlong */
if (cp >= 0xD800u && cp <= 0xDFFFu) return -2; /* surrogate */
n = 2;
} else if ((b0 & 0xF0u) == 0xE0u) {
/* 3-byte sequence */
if (*inb < 3) return -1;
unsigned char b1 = p[1];
unsigned char b2 = p[2];
if ((b1 & 0xC0u) != 0x80u || (b2 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x0Fu) << 12)
| ((uint32_t)(b1 & 0x3Fu) << 6)
| (uint32_t)(b2 & 0x3Fu);
if (cp < 0x800u) return -2; /* overlong */
if (cp >= 0xD800u && cp <= 0xDFFFu) return -2; /* surrogate */
n = 3;
} else if ((b0 & 0xF8u) == 0xF0u) {
/* 4-byte sequence */
if (*inb < 4) return -1;
unsigned char b1 = p[1];
unsigned char b2 = p[2];
unsigned char b3 = p[3];
if ((b1 & 0xC0u) != 0x80u ||
(b2 & 0xC0u) != 0x80u ||
(b3 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x07u) << 18)
| ((uint32_t)(b1 & 0x3Fu) << 12)
| ((uint32_t)(b2 & 0x3Fu) << 6)
| (uint32_t)(b3 & 0x3Fu);
if (cp < 0x10000u) return -2; /* overlong */
if (cp > 0x10FFFFu) return -2; /* out of range */
n = 4;
} else {
return -2; /* invalid lead */
}
size_t need = wrote_bom ? 4 : 8;
if (*outb < need) {
return -1;
}
unsigned char *o = (unsigned char *)*out;
/* Emit the native-endian BOM before the first character. */
if (!wrote_bom) {
utf32_encode(o, 0x0000FEFFu, UTF32_NATIVE_BIG_ENDIAN);
o += 4;
*out += 4;
*outb -= 4;
wrote_bom = 1;
}
/* Encode as native-endian 32-bit unit. */
utf32_encode(o, cp, UTF32_NATIVE_BIG_ENDIAN);
*in += n;
*inb -= n;
*out += 4;
*outb -= 4;
}
return 0;
}
+150
View File
@@ -0,0 +1,150 @@
/*
* libSemiOSCharsetUTF-32BE.so
* SemiOS charset library: UTF-32BE (big-endian, no BOM)
*/
#include <stdint.h>
#include <stddef.h>
#define SEMIOS_EXPORT __attribute__((visibility("default")))
SEMIOS_EXPORT
int SemiOS_Charset_UTF_32BE_ToUTF8(
char **restrict in, size_t *restrict inb,
char **restrict out, size_t *restrict outb
) {
while (*inb >= 4) {
const unsigned char *p = (const unsigned char *)*in;
/* Decode big-endian 32-bit code unit. */
uint32_t cp =
((uint32_t)p[0] << 24)
| ((uint32_t)p[1] << 16)
| ((uint32_t)p[2] << 8)
| (uint32_t)p[3];
/* Reject surrogates and out-of-Unicode-range values. */
if (cp > 0x10FFFFu || (cp >= 0xD800u && cp <= 0xDFFFu)) {
return -2;
}
/* Determine UTF-8 length. */
size_t n;
if (cp < 0x80u) n = 1;
else if (cp < 0x800u) n = 2;
else if (cp < 0x10000u) n = 3;
else n = 4;
if (*outb < n) {
return -1;
}
/* Encode into UTF-8. */
unsigned char *o = (unsigned char *)*out;
if (n == 1) {
o[0] = (unsigned char)cp;
} else if (n == 2) {
o[0] = (unsigned char)(0xC0u | (cp >> 6));
o[1] = (unsigned char)(0x80u | (cp & 0x3Fu));
} else if (n == 3) {
o[0] = (unsigned char)(0xE0u | (cp >> 12));
o[1] = (unsigned char)(0x80u | ((cp >> 6) & 0x3Fu));
o[2] = (unsigned char)(0x80u | (cp & 0x3Fu));
} else {
o[0] = (unsigned char)(0xF0u | (cp >> 18));
o[1] = (unsigned char)(0x80u | ((cp >> 12) & 0x3Fu));
o[2] = (unsigned char)(0x80u | ((cp >> 6) & 0x3Fu));
o[3] = (unsigned char)(0x80u | (cp & 0x3Fu));
}
*in += 4;
*inb -= 4;
*out += n;
*outb -= n;
}
/* If any input remains, it is a partial 32-bit unit. */
return *inb == 0 ? 0 : -1;
}
SEMIOS_EXPORT
int SemiOS_Charset_UTF_32BE_FromUTF8(
char **restrict in, size_t *restrict inb,
char **restrict out, size_t *restrict outb
) {
while (*inb > 0) {
const unsigned char *p = (const unsigned char *)*in;
unsigned char b0 = p[0];
uint32_t cp;
size_t n;
if (b0 < 0x80u) {
/* ASCII */
cp = b0;
n = 1;
} else if ((b0 & 0xE0u) == 0xC0u) {
/* 2-byte sequence */
if (*inb < 2) return -1;
unsigned char b1 = p[1];
if ((b1 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x1Fu) << 6)
| (uint32_t)(b1 & 0x3Fu);
if (cp < 0x80u) return -2; /* overlong */
if (cp >= 0xD800u && cp <= 0xDFFFu) return -2; /* surrogate */
n = 2;
} else if ((b0 & 0xF0u) == 0xE0u) {
/* 3-byte sequence */
if (*inb < 3) return -1;
unsigned char b1 = p[1];
unsigned char b2 = p[2];
if ((b1 & 0xC0u) != 0x80u || (b2 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x0Fu) << 12)
| ((uint32_t)(b1 & 0x3Fu) << 6)
| (uint32_t)(b2 & 0x3Fu);
if (cp < 0x800u) return -2; /* overlong */
if (cp >= 0xD800u && cp <= 0xDFFFu) return -2; /* surrogate */
n = 3;
} else if ((b0 & 0xF8u) == 0xF0u) {
/* 4-byte sequence */
if (*inb < 4) return -1;
unsigned char b1 = p[1];
unsigned char b2 = p[2];
unsigned char b3 = p[3];
if ((b1 & 0xC0u) != 0x80u ||
(b2 & 0xC0u) != 0x80u ||
(b3 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x07u) << 18)
| ((uint32_t)(b1 & 0x3Fu) << 12)
| ((uint32_t)(b2 & 0x3Fu) << 6)
| (uint32_t)(b3 & 0x3Fu);
if (cp < 0x10000u) return -2; /* overlong */
if (cp > 0x10FFFFu) return -2; /* out of range */
n = 4;
} else {
return -2; /* invalid lead */
}
if (*outb < 4) {
return -1;
}
/* Encode as big-endian 32-bit unit. */
unsigned char *o = (unsigned char *)*out;
o[0] = (unsigned char)((cp >> 24) & 0xFFu);
o[1] = (unsigned char)((cp >> 16) & 0xFFu);
o[2] = (unsigned char)((cp >> 8) & 0xFFu);
o[3] = (unsigned char)( cp & 0xFFu);
*in += n;
*inb -= n;
*out += 4;
*outb -= 4;
}
return 0;
}
+150
View File
@@ -0,0 +1,150 @@
/*
* libSemiOSCharsetUTF-32LE.so
* SemiOS charset library: UTF-32LE (little-endian, no BOM)
*/
#include <stdint.h>
#include <stddef.h>
#define SEMIOS_EXPORT __attribute__((visibility("default")))
SEMIOS_EXPORT
int SemiOS_Charset_UTF_32LE_ToUTF8(
char **restrict in, size_t *restrict inb,
char **restrict out, size_t *restrict outb
) {
while (*inb >= 4) {
const unsigned char *p = (const unsigned char *)*in;
/* Decode little-endian 32-bit code unit. */
uint32_t cp =
(uint32_t)p[0]
| ((uint32_t)p[1] << 8)
| ((uint32_t)p[2] << 16)
| ((uint32_t)p[3] << 24);
/* Reject surrogates and out-of-Unicode-range values. */
if (cp > 0x10FFFFu || (cp >= 0xD800u && cp <= 0xDFFFu)) {
return -2;
}
/* Determine UTF-8 length. */
size_t n;
if (cp < 0x80u) n = 1;
else if (cp < 0x800u) n = 2;
else if (cp < 0x10000u) n = 3;
else n = 4;
if (*outb < n) {
return -1;
}
/* Encode into UTF-8. */
unsigned char *o = (unsigned char *)*out;
if (n == 1) {
o[0] = (unsigned char)cp;
} else if (n == 2) {
o[0] = (unsigned char)(0xC0u | (cp >> 6));
o[1] = (unsigned char)(0x80u | (cp & 0x3Fu));
} else if (n == 3) {
o[0] = (unsigned char)(0xE0u | (cp >> 12));
o[1] = (unsigned char)(0x80u | ((cp >> 6) & 0x3Fu));
o[2] = (unsigned char)(0x80u | (cp & 0x3Fu));
} else {
o[0] = (unsigned char)(0xF0u | (cp >> 18));
o[1] = (unsigned char)(0x80u | ((cp >> 12) & 0x3Fu));
o[2] = (unsigned char)(0x80u | ((cp >> 6) & 0x3Fu));
o[3] = (unsigned char)(0x80u | (cp & 0x3Fu));
}
*in += 4;
*inb -= 4;
*out += n;
*outb -= n;
}
/* If any input remains, it is a partial 32-bit unit. */
return *inb == 0 ? 0 : -1;
}
SEMIOS_EXPORT
int SemiOS_Charset_UTF_32LE_FromUTF8(
char **restrict in, size_t *restrict inb,
char **restrict out, size_t *restrict outb
) {
while (*inb > 0) {
const unsigned char *p = (const unsigned char *)*in;
unsigned char b0 = p[0];
uint32_t cp;
size_t n;
if (b0 < 0x80u) {
/* ASCII */
cp = b0;
n = 1;
} else if ((b0 & 0xE0u) == 0xC0u) {
/* 2-byte sequence */
if (*inb < 2) return -1;
unsigned char b1 = p[1];
if ((b1 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x1Fu) << 6)
| (uint32_t)(b1 & 0x3Fu);
if (cp < 0x80u) return -2; /* overlong */
if (cp >= 0xD800u && cp <= 0xDFFFu) return -2; /* surrogate */
n = 2;
} else if ((b0 & 0xF0u) == 0xE0u) {
/* 3-byte sequence */
if (*inb < 3) return -1;
unsigned char b1 = p[1];
unsigned char b2 = p[2];
if ((b1 & 0xC0u) != 0x80u || (b2 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x0Fu) << 12)
| ((uint32_t)(b1 & 0x3Fu) << 6)
| (uint32_t)(b2 & 0x3Fu);
if (cp < 0x800u) return -2; /* overlong */
if (cp >= 0xD800u && cp <= 0xDFFFu) return -2; /* surrogate */
n = 3;
} else if ((b0 & 0xF8u) == 0xF0u) {
/* 4-byte sequence */
if (*inb < 4) return -1;
unsigned char b1 = p[1];
unsigned char b2 = p[2];
unsigned char b3 = p[3];
if ((b1 & 0xC0u) != 0x80u ||
(b2 & 0xC0u) != 0x80u ||
(b3 & 0xC0u) != 0x80u) return -2;
cp = ((uint32_t)(b0 & 0x07u) << 18)
| ((uint32_t)(b1 & 0x3Fu) << 12)
| ((uint32_t)(b2 & 0x3Fu) << 6)
| (uint32_t)(b3 & 0x3Fu);
if (cp < 0x10000u) return -2; /* overlong */
if (cp > 0x10FFFFu) return -2; /* out of range */
n = 4;
} else {
return -2; /* invalid lead */
}
if (*outb < 4) {
return -1;
}
/* Encode as little-endian 32-bit unit. */
unsigned char *o = (unsigned char *)*out;
o[0] = (unsigned char)( cp & 0xFFu);
o[1] = (unsigned char)((cp >> 8) & 0xFFu);
o[2] = (unsigned char)((cp >> 16) & 0xFFu);
o[3] = (unsigned char)((cp >> 24) & 0xFFu);
*in += n;
*inb -= n;
*out += 4;
*outb -= 4;
}
return 0;
}
Executable
+61
View File
@@ -0,0 +1,61 @@
#!/bin/sh
CC=${CC:-cc}
CFLAGS=${CFLAGS:-"-O2"}
LDFLAGS=${LDFLAGS:-""}
ENDIANNESS=${ENDIANNESS:-"little"}
# UTF-16
${CC} ${CFLAGS} -o UTF-16.o -c UTF-16.c || exit 1
${CC} ${LDFLAGS} -shared -o libSemiOSCharsetUTF-16.so UTF-16.o || exit 1
# UTF-16LE
${CC} ${CFLAGS} -o UTF-16LE.o -c UTF-16LE.c || exit 1
${CC} ${LDFLAGS} -shared -o libSemiOSCharsetUTF-16LE.so UTF-16LE.o || exit 1
if [ "$ENDIANNESS" = "little" ]; then
ln -sf libSemiOSCharsetUTF-16LE.so libSemiOSCharsetUTF-16-INTERNAL.so
fi
# UTF-16BE
${CC} ${CFLAGS} -o UTF-16BE.o -c UTF-16BE.c || exit 1
${CC} ${LDFLAGS} -shared -o libSemiOSCharsetUTF-16BE.so UTF-16BE.o || exit 1
if [ "$ENDIANNESS" = "big" ]; then
ln -sf libSemiOSCharsetUTF-16BE.so libSemiOSCharsetUTF-16-INTERNAL.so
fi
# UTF-32
${CC} ${CFLAGS} -o UTF-32.o -c UTF-32.c || exit 1
${CC} ${LDFLAGS} -shared -o libSemiOSCharsetUTF-32.so UTF-32.o || exit 1
ln -sf libSemiOSCharsetUTF-32.so libSemiOSCharsetUCS-4.so
# UTF-32LE
${CC} ${CFLAGS} -o UTF-32LE.o -c UTF-32LE.c || exit 1
${CC} ${LDFLAGS} -shared -o libSemiOSCharsetUTF-32LE.so UTF-32LE.o || exit 1
if [ "$ENDIANNESS" = "little" ]; then
ln -sf libSemiOSCharsetUTF-32LE.so libSemiOSCharsetUTF-32-INTERNAL.so
ln -sf libSemiOSCharsetUTF-32LE.so libSemiOSCharsetUCS-4-INTERNAL.so
fi
ln -sf libSemiOSCharsetUTF-32LE.so libSemiOSCharsetUCS-4LE.so
# UTF-32BE
${CC} ${CFLAGS} -o UTF-32BE.o -c UTF-32BE.c || exit 1
${CC} ${LDFLAGS} -shared -o libSemiOSCharsetUTF-32BE.so UTF-32BE.o || exit 1
if [ "$ENDIANNESS" = "big" ]; then
ln -sf libSemiOSCharsetUTF-32BE.so libSemiOSCharsetUTF-32-INTERNAL.so
ln -sf libSemiOSCharsetUTF-32BE.so libSemiOSCharsetUCS-4-INTERNAL.so
fi
ln -sf libSemiOSCharsetUTF-32BE.so libSemiOSCharsetUCS-4BE.so
# WCHAR_T
ln -sf libSemiOSCharsetUTF-32-INTERNAL.so libSemiOSCharsetWCHAR_T.so
# CP850
${CC} ${CFLAGS} -o CP850.o -c CP850.c || exit 1
${CC} ${LDFLAGS} -shared -o libSemiOSCharsetCP850.so CP850.o || exit 1
ln -sf libSemiOSCharsetCP850.so libSemiOSCharsetIBM850.so
ln -sf libSemiOSCharsetCP850.so libSemiOSCharsetIBM-850.so
ln -sf libSemiOSCharsetCP850.so libSemiOSCharset850.so
# GB18030
${CC} ${CFLAGS} -o GB18030.o -c GB18030.c || exit 1
${CC} ${LDFLAGS} -shared -o libSemiOSCharsetGB18030.so GB18030.o || exit 1
Executable
+4
View File
@@ -0,0 +1,4 @@
#!/bin/sh
cd $(dirname $0)
rm *.o *.so