00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#include <stdio.h>
00022
00023
#include "nt.h"
00024
#include "ntrtl.h"
00025
00026 #define NELEM(p) (sizeof(p) / sizeof(*(p)))
00027
00028 char OEMBuff[1000];
00029 char ABuff[1000];
00030 WCHAR
UBuff[2000];
00031
00032
int
00033 main(
00034
int argc,
00035
char *argv[]
00036 )
00037 {
00038 ULONG j;
00039 ULONG cb;
00040
char *pch;
00041
00042 printf(
"Start NlsXlatTest()\n");
00043
00044
00045
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
00055
00056
00057
00058 printf(
"Test 1: MultiByteToUnicodeN & RtlUnicodeToMultiByteN\n");
00059
00060
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
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 }