anchor.diff:  { TBuffConvEstonian922 }
   
   //-- BG ---------------------------------------------------------- 03.10.2012 --
  -function TBuffConvEstonian922.NextChar: WideChar;
  +function TBuffConvEstonian922.NextChar: TBuffChar;
   begin
     Result := TBuffChar(GetNext);
     case Ord(Result) of
  
positive.code: { TBuffConvEUC_KR }
  
  //-- BG ---------------------------------------------------------- 02.10.2012 --
  function TBuffConvEUC_KR.TwoByteDecoder(c1, c2: Byte): WideChar;
  begin
    Result := KSC5601DecodeChar(c1, c2);
  end;
  
negative.code:     case c1 of
        $A1..$A2:
          case c2 of
            $40..$7E: Result := TBuffChar($E4C6 + 96 * (c1 - $81) + (c2 - $40));
            $80..$A0: Result := TBuffChar($E4C6 + 96 * (c1 - $A1) + (c2 - $41));
          end;
  
        $AA..$AF, $F8..$FE:
          case c2 of
            $A1..$F7: Result := TBuffChar($E000 + 94 * (c1 - $AA) + (c2 - $A1));
            $F8..$FE: Result := TBuffChar($E000 + 94 * (c1 - $F2) + (c2 - $A1));
          end;
      end;
    end;
  end;
  
  { TBuffConvHangeul949 }
  
  //-- BG ---------------------------------------------------------- 04.10.2012 --
  function TBuffConvHangeul949.NextChar: TBuffChar;
  
    function UHC1Decode(row, col: Integer): TBuffChar;
    var
      I: Integer;
    begin
      i := 178 * row + col;
      if i < 5696 then
      begin
        if col >= 89 then
          Result := TBuffChar(UHC_1_1Map[2 * row + 1] + UHC_1_2Map[i])
        else
          Result := TBuffChar(UHC_1_1Map[2 * row] + UHC_1_2Map[i])
      end
      else
        Result := #$FFFD;
    end;
  
    function UHC2Decode(row, col: Integer): TBuffChar;
    var
      I: Integer;
    begin
      i := 84 * row + col;
      if i < 3126 then
      begin
        if col >= 42 then
          Result := TBuffChar(UHC_2_1Map[2 * row + 1] + UHC_2_2Map[i])
        else
          Result := TBuffChar(UHC_2_1Map[2 * row] + UHC_2_2Map[i])
      end
      else
        Result := #$FFFD;
    end;
  
    function KSC5601Decode(c1, c2: Integer): TBuffChar;
    begin
      Result := KSC5601DecodeChar(c1 - $80, c2 - $80);
      if Result = #0 then
        Result := #$FFFD;
    end;
  
  var
    c1, c2: Cardinal;
  begin
    c1 := GetNext;
    case c1 of
      $00..$7F: Result := TBuffChar(c1);
  
      $81..$A0:
      begin
        c2 := GetNext;
        case c2 of
          $40..$5A: Result := UHC1Decode(c1 - $81, c2 - $41);
          $61..$7A: Result := UHC1Decode(c1 - $81, c2 - $47);
          $81..$FE: Result := UHC1Decode(c1 - $81, c2 - $4D);
        else
          Result := TBuffChar($FFFD);
        end;
      end;
  
      $A1..$C5:
      begin
        c2 := GetNext;
        case c2 of
          $40..$5A: Result := UHC2Decode(c1 - $A1, c2 - $41);
          $61..$7A: Result := UHC2Decode(c1 - $A1, c2 - $47);
          $81..$A0: Result := UHC2Decode(c1 - $A1, c2 - $4D);
  
          $A1..$E7, $E9..$FE: Result := KSC5601Decode(c1, c2);
  
          $E8:
            if c1 <> $A2 then
              Result := KSC5601Decode(c1, c2)
            else
              Result := TBuffChar($FFFD);
  
        else
          Result := TBuffChar($FFFD);
        end;
      end;
  
      $C6..$FD:
      begin
        c2 := GetNext;
        Result := KSC5601Decode(c1, c2);
      end;
  
      $FE:
      begin
        c2 := GetNext;
        Result := TBuffChar($E000 + (c2 - $A1));
      end;
  
    else
      Result := TBuffChar($FFFD);
    end;
  end;
  
  { TBuffConvBig5CP950 }
  
  //-- BG ---------------------------------------------------------- 04.10.2012 --
  function TBuffConvBig5CP950.NextChar: TBuffChar;
  
    function CP950Decode1(row, col: Integer): TBuffChar;
    var
      i: Integer;
    begin
      i := 157 * row + col;
      Result := CP950Map[i];
    end;
  
    function BIG5Decode(row, col: Integer): TBuffChar;
    var
      i: Integer;
    begin
      i := 157 * row + col;
      case i of
           0.. 6120: Result := BIG5_1Map[i];
        6280..13931: Result := BIG5_2Map[i - 6280];
      else
        Result := TBuffChar($FFFD);
      end;
    end;
  
  var
    c1, c2, cc: Cardinal;
  begin
    c1 := GetNext;
    case c1 of
      $00..$7F: Result := TBuffChar(c1);    // ANSI/ASCII
      $80, $FF: Result := TBuffChar($FFFD); // undefined
      $81..$A0: Result := TBuffChar($FFFD); // private
  
      $A1..$A2:
      begin
        c2 := GetNext;
        case c2 of
          $40..$7E: Result := CP950Decode1(c1 - $A1, c2 - $40);
          $A1..$FE: Result := CP950Decode1(c1 - $A1, c2 - $62);
        else
          Result := TBuffChar($FFFD);
        end;
      end;
  
      $A3..$F9:
      begin
        c2 := GetNext;
        cc := c1 shl 8 + c2;
        case cc of
          $A3E1:        Result := TBuffChar($20AC); // Euro sign
          $C6A1..$C6FE,
          $C800..$C8FE: Result := TBuffChar($FFFD); // private
          $F9D6..$F9FE: Result := CP950EMap[c2 - $D6];
          $F9FF..$FEFE: Result := TBuffChar($FFFD); // private
        else
          case c2 of
            $40..$7E: Result := BIG5Decode(c1 - $A1, c2 - $40);
            $A1..$FE: Result := BIG5Decode(c1 - $A1, c2 - $62);
          else
            Result := TBuffChar($FFFD);
          end;
        end;
      end;
    else
      Result := TBuffChar($FFFD);
    end;
  end;
  
  { TBuffConvEUC_JP }
  
  function TBuffConvEUC_JP.NextChar: TBuffChar;
  var
    c1, c2, c3: Cardinal;
  begin
    c1 := GetNext;
    case c1 of
      $00..$7F: Result := TBuffChar(c1);    // ANSI/ASCII
      $80, $FF: Result := TBuffChar($FFFD); // undefined
      // $81..$A0: Result := TBuffChar($FFFD);
  
      $8E:
      begin
        // two byte code
        c2 := GetNext;
        case c2 of
          $A1..$DF: Result := JIS_X0201DecodeChar(c2);
        else
          Result := TBuffChar($FFFD);
        end;
      end;
  
      $8F:
      begin
        // three byte code
        c2 := GetNext;
        c3 := GetNext;
        case c2 of
          $A1..$F4:
            case c3 of
              $A1..$FE: Result := JIS_X0212DecodeChar(c2 - $80, c3 - $80);
            else
              Result := TBuffChar($FFFD);
            end;
  
          $F5..$FE:
            case c3 of
              $A1..$FE: Result := TBuffChar($E3AC + 94 * (c2 - $F5) + (c3 - $A1));
            else
              Result := TBuffChar($FFFD);
            end;
        else
          Result := TBuffChar($FFFD);
        end;
      end;
  
      $A1..$F4:
      begin
        // two byte code
        c2 := GetNext;
        Result := JIS_X0208DecodeChar(c1 - $80, c2 - $80);
      end;
  
      $F5..$FE:
      begin
        // two byte code
        c2 := GetNext;
        case c2 of
          $A1..$FE: Result := TBuffChar($E000 + 94 * (c1 - $F5) + (c2 - $A1));
        else
          Result := TBuffChar($FFFD);
        end;
      end;
    end;
  end;
  