test: tnlsxlat.c File Reference

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# tnlsxlat.c File Reference

`#include <stdio.h>`
`#include "nt.h"`
`#include "ntrtl.h"`

Go to the source code of this file.

## Defines

#define | NELEM(p) (sizeof(p) / sizeof(*(p)))

## Functions

int | main (int argc, char *argv[])

## Variables

char | OEMBuff [1000]
char | ABuff [1000]
WCHAR | UBuff [2000]

## Define Documentation

#define NELEM | ( | p |  | ) | (sizeof(p) / sizeof(*(p)))

| Definition at line 26 of file tnlsxlat.c. Referenced by ConsoleClientConnectRoutine(), GetRegistryValues(), InitializeConsoleHandleTable(), InitializeFonts(), InitSystemMenu(), MyModifyMenuItem(), ProcessCreateConsoleWindow(), and ProcessCtrlEvents().

## Function Documentation

int main | ( | int | argc,
|  | char * | argv[]
| ) |

Definition at line 33 of file tnlsxlat.c.

References ABuff, FALSE, OEMBuff, RtlMultiByteToUnicodeN(), RtlUnicodeToMultiByteN(), TRUE, and UBuff.

    00037 {
    00038     ULONG j;
    00039     ULONG cb;
    00040     char *pch;
    00041
    00042     printf("Start NlsXlatTest()\n");
    00043
    00044     //
    00045     //  First initialize the buffers
    00046     //
    00047
    00048     for (j = 0; j < sizeof(OEMBuff); j++) {
    00049         OEMBuff[j] = (char)(j * 17);
    00050         ABuff[j] = (char)(j * 19);
    00051     }
    00052
    00053     //
    00054     //  TEST 1
    00055     //  RtlMultiByteToUnicodeN, RtlUnicodeToMultiByteN
    00056     //
    00057
    00058     printf("Test 1: MultiByteToUnicodeN & RtlUnicodeToMultiByteN\n");
    00059
    00060     // TEST 1.1
    00061     //
    00062     printf("  Test 1.1: A->U U->A\n");
    00063
    00064     RtlMultiByteToUnicodeN(UBuff, sizeof(UBuff), &cb, ABuff, sizeof(ABuff));
    00065     printf("    %d bytes converted to Unicode\n", cb);
    00066     RtlUnicodeToMultiByteN(ABuff, sizeof(ABuff), &cb, UBuff, sizeof(UBuff));
    00067     printf("    %d bytes converted back to ANSI\n", cb);
    00068
    00069     for (j = 0; j < sizeof(ABuff); j++) {
    00070         if (ABuff[j] != (char)(j * 19)) {
    00071             printf("ABuff[%d] was 0x%02x, now 0x%02x\n",
    00072                     j, (char)(j * 19), ABuff[j]);
    00073             return FALSE;
    00074         }
    00075     }
    00076     printf("    Test 1.1 OK\n");
    00077
    00078     // TEST 1.2
    00079     //
    00080     printf("  Test 1.2: A->U U->A (source & dest buffers the same)\n");
    00081     RtlCopyMemory(UBuff, ABuff, sizeof(ABuff));
    00082
    00083     RtlMultiByteToUnicodeN(UBuff, sizeof(UBuff), &cb, UBuff, sizeof(ABuff));
    00084     printf("    %d bytes converted to Unicode\n", cb);
    00085     RtlUnicodeToMultiByteN(UBuff, sizeof(ABuff), &cb, UBuff, sizeof(UBuff));
    00086     printf("    %d bytes converted back to ANSI\n", cb);
    00087
    00088     pch = (LPSTR)UBuff;
    00089     for (j = 0; j < sizeof(ABuff); j++) {
    00090         if (pch[j] != ABuff[j]) {
    00091             printf("    ABuff[%d] was 0x%02x, was turned into 0x%02x\n",
    00092                     j, ABuff[j], pch[j]);
    00093             printf("    Test 1.2 FAILED!\n");
    00094             return FALSE;
    00095         }
    00096     }
    00097
    00098     printf("    Test 1.2 OK!\n");
    00099
    00100     return TRUE;
    00101 }

## Variable Documentation

char ABuff[1000]

| Definition at line 29 of file tnlsxlat.c. Referenced by main().

char OEMBuff[1000]

| Definition at line 28 of file tnlsxlat.c. Referenced by main().

WCHAR UBuff[2000]

| Definition at line 30 of file tnlsxlat.c. Referenced by main().