/// <summary>Encodes the given extra code info in the given stream.</summary> /// <remarks>Encodes the given extra code info in the given stream.</remarks> /// <exception cref="System.IO.IOException"></exception> private static void WriteExtraCodes(int charOffset, byte[] bytes, byte extraCodeModifier , GeneralLegacyIndexCodes.ExtraCodesStream extraCodes) { // we fill in a placeholder value for any chars w/out extra codes int numChars = extraCodes.GetNumChars(); if (numChars < charOffset) { int fillChars = charOffset - numChars; extraCodes.WriteFill(fillChars, INTERNATIONAL_EXTRA_PLACEHOLDER); extraCodes.IncrementNumChars(fillChars); } if (bytes != null) { // write the actual extra codes and update the number of chars extraCodes.Write(bytes); extraCodes.IncrementNumChars(1); } else { // extra code modifiers modify the existing extra code bytes and do not // count as additional extra code chars int lastIdx = extraCodes.GetLength() - 1; if (lastIdx >= 0) { // the extra code modifier is added to the last extra code written byte lastByte = extraCodes.Get(lastIdx); lastByte += extraCodeModifier; extraCodes.Set(lastIdx, lastByte); } else { // there is no previous extra code, add a new code (but keep track of // this "unprintable code" prefix) extraCodes.Write(extraCodeModifier); extraCodes.SetUnprintablePrefixLen(1); } } }