ftp.nice.ch/pub/next/graphics/convertors/Convert_PICT.NIHS.bs.tar.gz#/Convert_PICT/Source/shared.subproj/testMac2NeXT.m

This is testMac2NeXT.m in view mode; [Download] [Up]

#import "MacToNeXTText.h"
#import "common.h"
#import <stdio.h>

void main()
{
	Instance	converter;
	Integer	index;
	Character	theChar, strictChar;
	CString		source = "Hi there how are you doing?";
	ErrorCode		errorone, errortwo;
	FILE*	theFile;
	CString	result, buffer;
	Integer	resultsize;
	Integer	ctr, colctr = 1;

	converter = [[MacToNeXTText alloc] init];
	//
	//	Convert an ascii char, an existing 8 bit char, and a characcter we know won't convert
	//
	printf("Character A: %c (bool result: %d)\n",
		[converter ConvertCharacter: 'A'],
		[converter GetBooleanFrom: SECOND_RESULT]);

	printf("Character paragraph: %c (bool result: %d)\n",
		[converter ConvertCharacter: 0xA6],
		[converter GetBooleanFrom: SECOND_RESULT]);

	printf("Can't convert apple : %c  (bool result: %d)\n",
		[converter ConvertCharacter: 0xF0],
		[converter GetBooleanFrom: SECOND_RESULT]);
	for (index = 0; index < 256; index++)
	{
		theChar = [converter ConvertCharacter: index];
		[converter UseIM1: YES];
		errorone = [converter GetErrorCode];
		strictChar = [converter ConvertCharacter: index];
		[converter UseIM1: NO];
		errortwo = [converter GetErrorCode];
		printf("Converting Mac 0x%X to NeXT 0x%X (%c)  (error: %d) [strict: 0x%X (%c) (error: %d)]\n",
			index,
			theChar, theChar, errorone,
			strictChar, strictChar, errortwo);
	}

	// part two.
	buffer = NewCString(512);
	
	for (ctr = 0; ctr < 256; ctr++)
	{
		if (colctr != 16)
		{
			buffer[ctr*2] = ctr;
			buffer[(ctr*2)+1] = ' ';
			colctr++;
		}
		else
		{
			buffer[ctr*2] = ctr;
			buffer[(ctr*2)+1] = '\r';
			colctr = 1;
		}
	}
	buffer[512] = EndOfCString;
	printf("Source text is: \n%s\n", &buffer[1]); // skip initial null
	result =(CString)  [converter ConvertString: (Pointer) buffer WithLength: 512];
	resultsize = [converter GetIntegerFrom: SECOND_RESULT];
	printf("Size of result: %d\n", resultsize);
	printf("Results text is: \n");
	for (ctr = 0; ctr < resultsize; ctr ++)
		printf("%c", result[ctr]);
	printf("\n");
	//	test that it expands its internal buffer alright by giving it some text which we
	//	know will multiply in size when it comes out. .. convert lots of apples
	for (ctr = 0; ctr < 16; ctr++)
		buffer[ctr] = 0xF0;
	buffer[16] = EndOfCString;
	printf("Source text is: \n%s\n", (CString)buffer);
	result =(CString)  [converter ConvertString: (Pointer) buffer WithLength: 16];
	resultsize = [converter GetIntegerFrom: SECOND_RESULT];
	printf("Size of result: %d\n", resultsize);
	printf("Results text is: \n");
	for (ctr = 0; ctr < resultsize; ctr ++)
		printf("%c", result[ctr]);
	printf("\n");
	
	FreePointer(result);
	FreePointer(buffer);
	close(theFile);
	[converter	free];
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.