69 lines
1.9 KiB
C
69 lines
1.9 KiB
C
#include "library/xUnicode.h"
|
|
#include "unicodeInit.h"
|
|
#include "public/zError.h"
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
extern STATUS LB_UnicodeStartup(void);
|
|
extern void LB_UnicodeShutdown(void);
|
|
extern STATUS LB_GetMacCodePageName(BYTE *nameBuffer, NINT bufferLen);
|
|
|
|
#define CHECK(expr) \
|
|
do { \
|
|
if (!(expr)) { \
|
|
fprintf(stderr, "CHECK failed at %s:%d: %s\n", __FILE__, __LINE__, #expr); \
|
|
return 1; \
|
|
} \
|
|
} while (0)
|
|
|
|
int main(void)
|
|
{
|
|
unicode_t unicode[32];
|
|
char bytes[32];
|
|
NINT actual = -1;
|
|
BYTE mac_name[64];
|
|
|
|
(void)mac_name;
|
|
|
|
CHECK(LB_UnicodeStartup() == zOK);
|
|
|
|
CHECK(LB_ByteToUnicode(NSS_UNI_CONVERSION_RAW, unicode,
|
|
(NINT)(sizeof(unicode) / sizeof(unicode[0])),
|
|
"MARS", &actual) == zOK);
|
|
CHECK(actual == 4);
|
|
CHECK(unicode[0] == 'M');
|
|
CHECK(unicode[3] == 'S');
|
|
CHECK(unicode[4] == 0);
|
|
|
|
CHECK(LB_UnicodeToByte(NSS_UNI_CONVERSION_RAW, bytes, sizeof(bytes),
|
|
unicode, &actual) == zOK);
|
|
CHECK(actual == 4);
|
|
CHECK(strcmp(bytes, "MARS") == 0);
|
|
|
|
CHECK(LB_LenByteToUnicode(NSS_UNI_CONVERSION_RAW, unicode,
|
|
(NINT)(sizeof(unicode) / sizeof(unicode[0])),
|
|
"MARS-NWE", 4, &actual) == zOK);
|
|
CHECK(actual == 4);
|
|
CHECK(unicode[4] == 0);
|
|
|
|
unicode[0] = 'O';
|
|
unicode[1] = 'K';
|
|
unicode[2] = 0;
|
|
CHECK(LB_UnicodeToUntermByte(NSS_UNI_CONVERSION_RAW, bytes, 2,
|
|
unicode, &actual) == zOK);
|
|
CHECK(actual == 2);
|
|
CHECK(bytes[0] == 'O');
|
|
CHECK(bytes[1] == 'K');
|
|
|
|
CHECK(LB_GetMacCodePageName(mac_name, sizeof(mac_name)) == zERR_NO_FILES_FOUND);
|
|
|
|
LB_UnicodeShutdown();
|
|
CHECK(LB_UnicodeStartup() == zOK);
|
|
CHECK(LB_ByteToUnicode(NSS_UNI_CONVERSION_RAW, unicode,
|
|
(NINT)(sizeof(unicode) / sizeof(unicode[0])),
|
|
"X", &actual) == zOK);
|
|
CHECK(unicode[0] == 'X');
|
|
return 0;
|
|
}
|