Пример #1
0
ByteArray EncodingTable::encodeString(const std::wstring& str, bool writeTermination)
{
	ByteArray result;
	size_t pos = 0;

	while (pos < str.size())
	{
		int index = searchStringMatch(str,pos);
		if (index == -1)
		{
			// error
			return ByteArray();
		}

		TableEntry& entry = entries[index];
		for (int i = 0; i < entry.hexLen; i++)
		{
			result.appendByte(hexData[entry.hexPos+i]);
		}

		pos += entry.valueLen;
	}

	if (writeTermination)
	{
		TableEntry& entry = terminationEntry;
		for (int i = 0; i < entry.hexLen; i++)
		{
			result.appendByte(hexData[entry.hexPos+i]);
		}
	}

	return result;
}
Пример #2
0
ByteArray EncodingTable::encodeTermination()
{
	ByteArray result;

	TableEntry& entry = terminationEntry;
	for (int i = 0; i < entry.hexLen; i++)
	{
		result.appendByte(hexData[entry.hexPos+i]);
	}

	return result;
}