here - OSTA - Optical Storage Technology Association
here - OSTA - Optical Storage Technology Association
here - OSTA - Optical Storage Technology Association
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
6.4 <strong>OSTA</strong> Compressed Unicode Algorithm<br />
/***********************************************************************<br />
* <strong>OSTA</strong> compliant Unicode compression, uncompression routines.<br />
* Copyright 1995 Micro Design International, Inc.<br />
* Written by Jason M. Rinn.<br />
* Micro Design International gives permission for the free use of the<br />
* following source code.<br />
*/<br />
#include <br />
/***********************************************************************<br />
* The following two typedef's are to remove compiler dependancies.<br />
* byte needs to be unsigned 8-bit, and unicode_t needs to be<br />
* unsigned 16-bit.<br />
*/<br />
typedef unsigned short unicode_t;<br />
typedef unsigned char byte;<br />
/***********************************************************************<br />
* Takes an <strong>OSTA</strong> CS0 compressed unicode name, and converts<br />
* it to Unicode.<br />
* The Unicode output will be in the byte order<br />
* that the local compiler uses for 16-bit values.<br />
* NOTE: This routine only performs error checking on the compID.<br />
* It is up to the user to ensure that the unicode buffer is large<br />
* enough, and that the compressed unicode name is correct.<br />
*<br />
* RETURN VALUE<br />
*<br />
* The number of unicode characters which were uncompressed.<br />
* A -1 is returned if the compression ID is invalid.<br />
*/<br />
int UncompressUnicode(<br />
int numberOfBytes, /* (Input) number of bytes read from media. */<br />
byte *UDFCompressed, /* (Input) bytes read from media. */<br />
unicode_t *unicode) /* (Output) uncompressed unicode characters. */<br />
{<br />
unsigned int compID;<br />
int returnValue, unicodeIndex, byteIndex;<br />
/* Use UDFCompressed to store current byte being read. */<br />
compID = UDFCompressed[0];<br />
/* First check for valid compID. */<br />
if (compID != 8 && compID != 16)<br />
{<br />
returnValue = -1;<br />
}<br />
else<br />
{<br />
unicodeIndex = 0;<br />
byteIndex = 1;<br />
/* Loop through all the bytes. */<br />
while (byteIndex < numberOfBytes)<br />
{<br />
if (compID == 16)<br />
{<br />
/*Move the first byte to the high bits of the unicode char. */<br />
unicode[unicodeIndex] = UDFCompressed[byteIndex++]