Index: branch/egtra-stream-without-en_dec/Classes/System/IO/StreamReader.ab
===================================================================
--- branch/egtra-stream-without-en_dec/Classes/System/IO/StreamReader.ab	(revision 672)
+++ branch/egtra-stream-without-en_dec/Classes/System/IO/StreamReader.ab	(revision 673)
@@ -58,33 +58,40 @@
 	*/
 	Override Function Underflow() As Boolean
-		Dim wcBuf[4095] As WCHAR
-		Dim mbBuf[4095] As SByte
-		Dim pNext = mbBuf As PSTR
-		Dim mbBufSize = Len(buf)
-		If leadByte <> 0 Then
-			pNext[0] = leadByte
-			leadByte = 0
-			pNext++
-			mbBufSize--
-		End If
-		Dim mbLen = s.Read(pNext As *Byte, 0, mbBufSize)
-		If mbLen = 0 Then
+		Dim nextRead As *Byte
+		Dim readSize = s.Read(mbBuf + bufSize, 0, bufCapacity - bufSize)
+		If readSize = 0 Then
+			If bufSize <> 0 Then
+#ifdef UNCODE
+				Buffer.Append(&hfffd As WCHAR)
+#else
+				Buffer.Append("?")
+#endif
+			End If
 			Underflow = False
 			Exit Function
 		End If
+		Dim mbLen = bufSize + readSize
+		'文字全体が揃っている部分を抽出する。
+		Dim pNext = mbBuf
 		Do
-			Dim q = CharNextExA(cp, pNext, 0)
+			Dim q = e.NextChar(pNext, ((mbBuf + mbLen) - pNext) As Long)
 			If q = pNext Then
 				Exit Do
 			End If
-			pNext = q As PSTR
+			pNext = q
 		Loop
-		If pNext <> mbBuf + mbLen Then
-			leadByte = mbBuf[mbLen - 1]
+		'文字全体が揃っている部分を変換しTextReaderのバッファに送る。
+		Dim wcBufCapacity = e.GetMaxCharCount(mbLen)
+		Dim wcBuf = GC_malloc_atomic(wcBufCapacity * SizeOf (WCHAR)) As *WCHAR
+		Dim wcLen = e.GetChars(mbBuf, (pNext - mbBuf) As Long, wcBuf, wcBufCapacity)
+		Dim appendStr As PCTSTR
+		Dim appendLen = GetStr(wcBuf, wcLen As SIZE_T, appendStr)
+		Dim readerBuffer = Buffer
+		readerBuffer.Append(appendStr, 0, appendLen)
+		'マルチバイトの揃っていない部分を手前に連れてくる。
+		bufSize = ((mbBuf + mbLen) - pNext) As Long
+		If bufSize <> 0 Then
+			memmove(mbBuf, mbBuf + mbLen, bufSize)
 		End If
-		Dim wcLen = MultiByteToWideChar(cp, 0, mbBuf, (pNext - mbBuf) As Long, wcBuf, 4095)
-		Dim s = New String(wcBuf, wcLen)
-		Dim buf = Buffer
-		buf.Append(s)
 		Underflow = True
 	End Function
@@ -97,11 +104,15 @@
 	Sub init(str As Stream)
 		s = str
-		cp  = CP_ACP '暫定。
-		leadByte = 0
+		e = New Text.Detail.WindowsCodePageEncoding(CP_ACP) '暫定。
+		bufCapacity = 8192
+		mbBuf = GC_malloc_atomic(bufCapacity) As *Byte
+		bufSize = 0
 	End Sub
 
 	s As Stream
-	cp As Word
-	leadByte As Byte
+	e As Text.Encoding
+	mbBuf As *Byte
+	bufSize As Long
+	bufCapacity As Long
 End Class
 
Index: branch/egtra-stream-without-en_dec/Classes/System/IO/StreamWriter.ab
===================================================================
--- branch/egtra-stream-without-en_dec/Classes/System/IO/StreamWriter.ab	(revision 672)
+++ branch/egtra-stream-without-en_dec/Classes/System/IO/StreamWriter.ab	(revision 673)
@@ -41,20 +41,11 @@
 
 	Override Sub Flush()
-		Dim buf = Buffer()
-		Dim pws As PCWSTR
-		Dim size = GetWCStr(buf.ToString(), pws)
-		Dim pwsEnd = VarPtr(pws[size])
-		Dim charConverted As Long
-		Dim byteBuf[4095] As Byte
-		Dim byteSize As Long
-		Dim completed As Boolean
-		Do
-			Dim converted As Long
-			encoder.Convert(pws, size, byteBuf, Len(byteBuf), False, charConverted, byteSize, completed)
-			s.Write(byteBuf, 0, byteSize)
-			pws = VarPtr(pws[charConverted])
-			size -= charConverted
-		Loop Until pws = pwsEnd
-		buf.Length = 0
+		softFlush()
+		s.Flush()
+	End Sub
+
+	Override Sub WriteLine()
+		Super.WriteLine()
+		softFlush()
 	End Sub
 
@@ -63,5 +54,4 @@
 		If disposing Then
 			Flush()
-			flushLast()
 			s.Dispose()
 		End If
@@ -73,21 +63,18 @@
 		buf = New Text.StringBuilder(4096)
 		'暫定。正式版ではUTF-8を標準とする。
-		encoding = New Text.Detail.WindowsCodePageEncoding(CP_ACP)
-		encoder = encoding.GetEncoder()
+		e = New Text.Detail.WindowsCodePageEncoding(CP_ACP)
 	End Sub
 
-	Sub flushLast()
-		Dim charConverted As Long
-		Dim byteBuf[63] As Byte
-		Dim byteSize As Long
-		Dim completed As Boolean
-		Do
-			encoder.Convert(0, 0, byteBuf, Len(byteBuf), False, charConverted, byteSize, completed)
-			s.Write(byteBuf, 0, byteSize)
-		Loop Until completed
+	Sub softFlush()
+		Dim buf = Buffer()
+		Dim pws As PCWSTR
+		Dim wcSize = GetWCStr(buf.ToString(), pws)
+		Dim mbMaxSize = e.GetMaxByteCount(wcSize)
+		Dim mbBuf = GC_malloc_atomic(mbMaxSize) As *Byte
+		Dim mbBufSize = e.GetBytes(pws, wcSize, mbBuf, mbMaxSize)
+		s.Write(mbBuf, 0, mbBufSize)
 	End Sub
 
-	encoding As Text.Encoding
-	encoder As Text.Encoder
+	e As Text.Encoding
 	s As System.IO.Stream
 End Class
Index: branch/egtra-stream-without-en_dec/Classes/System/IO/TextWriter.ab
===================================================================
--- branch/egtra-stream-without-en_dec/Classes/System/IO/TextWriter.ab	(revision 672)
+++ branch/egtra-stream-without-en_dec/Classes/System/IO/TextWriter.ab	(revision 673)
@@ -86,5 +86,5 @@
 	End Sub
 
-	Sub WriteLine()
+	Virtual Sub WriteLine()
 		Write(Environment.NewLine)
 	End Sub
Index: branch/egtra-stream-without-en_dec/Classes/System/Text/Encoding.ab
===================================================================
--- branch/egtra-stream-without-en_dec/Classes/System/Text/Encoding.ab	(revision 672)
+++ branch/egtra-stream-without-en_dec/Classes/System/Text/Encoding.ab	(revision 673)
@@ -39,6 +39,6 @@
 	@brief	符号化して得られる文字列の長さを計算する。
 	@param[in] src	対象文字列
-	@param[in] srcCount	srcの長さ
-	@return	符号化して得られる文字列の長さ
+	@param[in] srcCount	srcの長さ（要素数単位）
+	@return	符号化して得られる文字列の長さ（要素数単位）
 	@date	2007/12/08
 	*/
@@ -55,5 +55,5 @@
 	@brief	符号化して得られる文字列の長さを計算する。
 	@param[in] src	対象文字列
-	@return	符号化して得られる文字列の長さ
+	@return	符号化して得られる文字列の長さ（要素数単位）
 	@date	2007/12/08
 	*/
@@ -66,24 +66,21 @@
 #endif
 
-Private
+Protected
 	/*!
 	@brief	GetBytesCountの実装を行う。
 	@param[in] src	対象文字列
-	@param[in] srcCount	srcの長さ
-	@return	符号化して得られる文字列の長さ
-	@date	2007/12/08
-	*/
-	Function GetBytesCountCore(src As *WCHAR, srcCount As Long) As Long
-		Dim enc = GetEncoder()
-		GetBytesCountCore = enc.GetBytesCount(src, srcCount, True)
-	End Function
+	@param[in] srcCount	srcの長さ（要素数単位）
+	@return	符号化して得られる文字列の長さ（要素数単位）
+	@date	2007/12/08
+	*/
+	Abstract Function GetBytesCountCore(src As *WCHAR, srcCount As Long) As Long
 Public
 	/*!
 	@brief	符号化する。
 	@param[in] src	入力
-	@param[in] srcCount	srcの長さ
+	@param[in] srcCount	srcの長さ（要素数単位）
 	@param[out] dst	出力
-	@param[in] dstCount	dstのバッファの大きさ
-	@return dstに書き込まれたバイト数
+	@param[in] dstCount	dstのバッファの大きさ（要素数単位）
+	@return dstに書き込まれた要素数
 	@date	2007/12/08
 	*/
@@ -102,24 +99,22 @@
 	End Function
 
-Private
+Protected
 	/*!
 	@brief	GetBytesの処理を行う。
 	@param[in] src	入力
-	@param[in] srcCount	srcの長さ
+	@param[in] srcCount	srcの長さ（要素数単位）
 	@param[out] dst	出力
-	@param[in] dstCount	dstのバッファの大きさ
-	@return dstに書き込まれたバイト数
+	@param[in] dstCount	dstのバッファの大きさ（要素数単位）
+	@return dstに書き込まれた要素数
 	@exception ArgumentException	バッファの大きさが足りない
 	@date	2007/12/08
 	*/
-	Function GetBytesCore(src As *WCHAR, srcCount As Long, dst As *Byte, dstCount As Long) As Long
-		GetBytesCore = GetEncoder().GetBytes(src, srcCount, dst, dstCount, True)
-	End Function
+	Abstract Function GetBytesCore(src As *WCHAR, srcCount As Long, dst As *Byte, dstCount As Long) As Long
 Public
 	/*!
 	@brief	復号して得られる文字列の長さを計算する。
 	@param[in] src	対象文字列
-	@param[in] srcCount	srcの長さ
-	@return	復号して得られる文字列の長さ
+	@param[in] srcCount	srcの長さ（要素数単位）
+	@return	復号して得られる文字列の長さ（要素数単位）
 	@date	2007/12/08
 	*/
@@ -133,24 +128,21 @@
 	End Function
 
-Private
+Protected
 	/*!
 	@brief	GetCharsCountの処理を行う。
 	@param[in] src	対象文字列
-	@param[in] srcCount	srcの長さ
-	@return	符号化して得られる文字列の長さ
-	@date	2007/12/08
-	*/
-	Function GetCharsCountCore(src As *Byte, srcCount As Long) As Long
-		Dim dec = GetDecoder()
-		GetCharsCountCore = dec.GetCharsCount(src, srcCount, True)
-	End Function
+	@param[in] srcCount	srcの長さ（要素数単位）
+	@return	符号化して得られる文字列の長さ（要素数単位）
+	@date	2007/12/08
+	*/
+	Abstract Function GetCharsCountCore(src As *Byte, srcCount As Long) As Long
 Public
 	/*!
 	@brief	復号する。
 	@param[in] src	入力
-	@param[in] srcCount	srcの長さ
+	@param[in] srcCount	srcの長さ（要素数単位）
 	@param[out] dst	出力
-	@param[in] dstCount	srcのバッファの大きさ
-	@return dstに書き込まれたバイト数
+	@param[in] dstCount	srcのバッファの大きさ（要素数単位）
+	@return dstに書き込まれた要素数
 	@date	2007/12/08
 	*/
@@ -169,18 +161,16 @@
 	End Function
 
-Private
+Protected
 	/*!
 	@brief	GetCharsの処理を行う。
 	@param[in] src	入力
-	@param[in] srcCount	srcの長さ
+	@param[in] srcCount	srcの長さ（要素数単位）
 	@param[out] dst	出力
-	@param[in] dstCount	dstのバッファの大きさ
-	@return dstに書き込まれたバイト数
+	@param[in] dstCount	dstのバッファの大きさ（要素数単位）
+	@return dstに書き込まれた要素数
 	@exception ArgumentException	バッファの大きさが足りない
 	@date	2007/12/08
 	*/
-	Function GetCharsCore(src As *Byte, srcCount As Long, dst As *WCHAR, dstCount As Long) As Long
-		GetCharsCore = GetDecoder().GetChars(src, srcCount, dst, dstCount, True)
-	End Function
+	Abstract Function GetCharsCore(src As *Byte, srcCount As Long, dst As *WCHAR, dstCount As Long) As Long
 Public
 #ifdef UNICODE
@@ -188,5 +178,5 @@
 	@brief	復号し、Stringで結果を返す。
 	@param[in] src	入力
-	@param[in] srcCount	srcの長さ
+	@param[in] srcCount	srcの長さ（要素数単位）
 	@return	変換結果の文字列
 	@date	2007/12/08
@@ -214,14 +204,4 @@
 Public
 	/*!
-	@brief	符号器を取得する。
-	*/
-	Abstract Function GetDecoder() As Decoder
-
-	/*!
-	@brief	復号器を取得する。
-	*/
-	Abstract Function GetEncoder() As Encoder
-
-	/*!
 	@brief	ある長さの文字列を符号化して得られるバイト列の最大の長さを返す。
 	*/
@@ -242,5 +222,5 @@
 
 	/*!
-	@brief	GetPreambleの配列の要素数
+	@brief	GetPreambleの配列の要素数。
 	*/
 	Virtual Function GetPreambleLength() As Long
@@ -248,4 +228,31 @@
 	End Function
 
+	/*!
+	@brief 与えられたバイト文字列から2文字目の開始地点を探す。
+	@param[in] s （マルチバイト）文字列
+	@param[in] count sの要素数
+	@return 2文字目の開始位置。2文字が存在しない場合、sを返す。
+	*/
+	Function NextChar(s As *Byte, count As Long) As *Byte
+		If count = 0 Then
+			NextChar = s
+		ElseIf s = 0 Then
+			Throw New ArgumentNullException("s")
+		ElseIf count < 0 Then
+			Throw New ArgumentException("count")
+		Else
+			NextChar = NextCharCore(s, count)
+		End If
+	End Function
+Protected
+	/*!
+	@brief NextCharの処理を行う。
+	@param[in] s （マルチバイト）文字列
+	@param[in] count sの要素数
+	@return 2文字目の開始位置。2文字が存在しない場合、sを返す。
+	*/
+	Abstract Function NextCharCore(s As *Byte, count As Long) As *Byte
+
+Public
 '	Abstract Function BodyName() As String
 '	Abstract Function HeaderName() As String
@@ -331,202 +338,4 @@
 End Class
 
-/*!
-@brief	復号を行うクラス
-@date	2007/12/19
-@auther	Egtra
-*/
-Class Decoder
-Public
-	/*!
-	@brief	変換する
-	@param[in] src	入力
-	@param[in] srcCount 入力要素数
-	@param[out] dst	出力
-	@param[in] dstCount 出力要素数
-	@param[in] flush	終了後に内部状態を初期化するかどうか
-	@param[out] srcUsed	使用された入力の要素数
-	@param[out] dstUsed	出力の内、実際に書き込まれた要素数
-	@param[out] completed	入力の全ての文字が変換に使われたかどうか
-	*/
-	Sub Convert(src As *Byte, srcCount As Long,
-		dst As *WCHAR, dstCount As Long, flush As Boolean,
-		ByRef srcUsed As Long, ByRef dstUsed As Long, ByRef completed As Boolean)
-
-		If src = 0 And srcCount > 0 Then
-			Throw New ArgumentNullException("src")
-		ElseIf srcCount < 0 Then
-			Throw New ArgumentOutOfRangeException("srcCount")
-		ElseIf dst = 0 Then
-			Throw New ArgumentNullException("dst")
-		ElseIf dstCount < 0 Then
-			Throw New ArgumentOutOfRangeException("dstCount")
-		End If
-		ConvertCore(src, srcCount, dst, dstCount, flush, srcUsed, dstUsed, completed)
-	End Sub
-
-	/*!
-	@brief	変換する
-	@param[in] src	入力
-	@param[in] srcCount 入力要素数
-	@param[out] dst	出力
-	@param[in] dstCount 出力要素数
-	@param[in] flush	終了後に内部状態を初期化するかどうか
-	@return 出力の内、実際に書き込まれた要素数
-	*/
-	Function GetChars(src As *Byte, srcCount As Long, dst As *WCHAR, dstCount As Long, flush As Boolean) As Long
-		Dim srcUsed As Long
-		Dim completed As Boolean
-		Convert(src, srcCount, dst, dstCount, flush, srcUsed, GetChars, completed)
-		If srcUsed < srcCount Then
-			Throw New ArgumentException("src", "buffer is too small")
-		End If
-	End Function
-
-	/*!
-	@brief	変換すると何文字になるか数える
-	@param[in] src	入力
-	@param[in] srcCount 入力要素数
-	@param[in] flush	終了後に内部状態を初期化するとして計算するかどうか
-	@return	必要な文字数
-	*/
-	Function GetCharsCount(src As *Byte, srcCount As Long, flush As Boolean) As Long
-		If src = 0 Then
-			Throw New ArgumentNullException("src")
-		ElseIf srcCount < 0 Then
-			Throw New ArgumentOutOfRangeException("srcCount")
-		End If
-		GetCharsCountCore(src, srcCount, flush)
-	End Function
-
-	/*!
-	@brief	内部状態を初期状態に戻す
-	*/
-	Virtual Sub Reset()
-	End Sub
-
-Protected
-	/*!
-	@brief	実際に変換する
-	@param[in] src	入力
-	@param[in] srcCount 入力要素数
-	@param[out] dst	出力
-	@param[in] dstCount 出力要素数
-	@param[in] flush	終了後に内部状態を初期化するかどうか
-	@param[out] dstUsed	使用された入力の要素数
-	@param[out] srcUsed	出力の内、実際に書き込まれた要素数
-	@param[out] completed	入力の全ての文字が変換に使われたかどうか
-	*/
-	Abstract Sub ConvertCore(src As *Byte, srcCount As Long, dst As *WCHAR, dstCount As Long, flush As Boolean,
-		ByRef srcUsed As Long, ByRef dstUsed As Long, ByRef completed As Boolean)
-
-	/*!
-	@brief	変換すると何文字になるか数える
-	@param[in] src	入力
-	@param[in] srcCount 入力要素数
-	@param[in] flush	終了後に内部状態を初期化するとして計算するかどうか
-	@return	必要な文字数
-	*/
-	Abstract Function GetCharsCountCore(src As *Byte, srcCount As Long, flush As Boolean) As Long
-End Class
-
-/*!
-@brief	符号化を行うクラス
-@date	2007/12/19
-@auther	Egtra
-*/
-Class Encoder
-Public
-	/*!
-	@brief	変換する
-	@param[in] src	入力
-	@param[in] srcCount 入力要素数
-	@param[out] dst	出力
-	@param[in] dstCount 出力要素数
-	@param[in] flush	終了後に内部状態を初期化するかどうか
-	@param[out] srcUsed	使用された入力の要素数
-	@param[out] dstUsed	出力の内、実際に書き込まれた要素数
-	@param[out] completed	入力の全ての文字が変換に使われたかどうか
-	*/
-	Sub Convert(src As *WCHAR, srcCount As Long,
-		dst As *Byte, dstCount As Long, flush As Boolean,
-		ByRef srcUsed As Long, ByRef dstUsed As Long, ByRef completed As Boolean)
-
-		If src = 0 And srcCount > 0 Then
-			Throw New ArgumentNullException("src")
-		ElseIf srcCount < 0 Then
-			Throw New ArgumentOutOfRangeException("srcCount")
-		ElseIf dst = 0 Then
-			Throw New ArgumentNullException("dst")
-		ElseIf dstCount < 0 Then
-			Throw New ArgumentOutOfRangeException("dstCount")
-		End If
-		ConvertCore(src, srcCount, dst, dstCount, flush, srcUsed, dstUsed, completed)
-	End Sub
-
-	/*!
-	@brief	変換する
-	@param[in] src	入力
-	@param[in] srcCount 入力要素数
-	@param[out] dst	出力
-	@param[in] dstCount 出力要素数
-	@param[in] flush	終了後に内部状態を初期化するかどうか
-	@return 出力の内、実際に書き込まれた要素数
-	*/
-	Function GetBytes(src As *WCHAR, srcCount As Long, dst As *Byte, dstCount As Long, flush As Boolean) As Long
-		Dim srcUsed As Long
-		Dim completed As Boolean
-		Convert(src, srcCount, dst, dstCount, flush, srcUsed, GetBytes, completed)
-		If srcUsed < srcCount Then
-			Throw New ArgumentException("src", "buffer is too small")
-		End If
-	End Function
-
-	/*!
-	@brief	変換すると何文字になるか数える
-	@param[in] src	入力
-	@param[in] srcCount 入力要素数
-	@param[in] flush	終了後に内部状態を初期化するとして計算するかどうか
-	@return	必要な文字数
-	*/
-	Function GetBytesCount(src As *WCHAR, srcCount As Long, flush As Boolean) As Long
-		If src = 0 Then
-			Throw New ArgumentNullException("src")
-		ElseIf srcCount < 0 Then
-			Throw New ArgumentOutOfRangeException("srcCount")
-		End If
-		GetBytesCountCore(src, srcCount, flush)
-	End Function
-
-	/*!
-	@brief	内部状態を初期状態に戻す
-	*/
-	Virtual Sub Reset()
-	End Sub
-
-Protected
-	/*!
-	@brief	実際に変換する
-	@param[in] src	入力
-	@param[in] srcCount 入力要素数
-	@param[out] dst	出力
-	@param[in] dstCount 出力要素数
-	@param[in] flush	終了後に内部状態を初期化するかどうか
-	@param[out] dstUsed	使用された入力の要素数
-	@param[out] srcUsed	出力の内、実際に書き込まれた要素数
-	@param[out] completed	入力の全ての文字が変換に使われたかどうか
-	*/
-	Abstract Sub ConvertCore(src As *WCHAR, srcCount As Long, dst As *Byte, dstCount As Long, flush As Boolean,
-		ByRef dstUsed As Long, ByRef srcUsed As Long, ByRef completed As Boolean)
-
-	/*!
-	@brief	変換すると何文字になるか数える
-	@param[in] src	入力
-	@param[in] srcCount 入力要素数
-	@param[in] flush	終了後に内部状態を初期化するとして計算するかどうか
-	@return	必要な文字数
-	*/
-	Abstract Function GetBytesCountCore(src As *WCHAR, srcCount As Long, flush As Boolean) As Long
-End Class
-
 Enum NormalizationForm
 	FormC
@@ -549,18 +358,4 @@
 	End Sub
 
-	/*!
-	@brief	符号器を取得する。
-	*/
-	Override Function GetDecoder() As Decoder
-		GetDecoder = New WindowsCodePageDecoder(cp)
-	End Function
-
-	/*!
-	@brief	復号器を取得する。
-	*/
-	Override Function GetEncoder() As Encoder
-		GetEncoder = New WindowsCodePageEncoder(cp)
-	End Function
-
 	Override Function GetHashCode() As Long
 		GetHashCode = cp As Long
@@ -590,119 +385,41 @@
 	End Function
 
+Protected
+	Override Function GetBytesCountCore(src As *WCHAR, srcCount As Long) As Long
+		GetBytesCountCore = WideCharToMultiByte(cp, 0, src, srcCount, 0, 0, 0, 0)
+		If srcCount <> 0 And GetBytesCountCore = 0 Then
+			ActiveBasic.Windows.ThrowWithLastError()
+		End If
+	End Function
+
+	Override Function GetBytesCore(src As *WCHAR, srcCount As Long, dst As *Byte, dstCount As Long) As Long
+		GetBytesCore = WideCharToMultiByte(cp, 0, src, srcCount, dst As PCSTR, dstCount, 0, 0)
+		If srcCount <> 0 And GetBytesCore = 0 Then
+			ActiveBasic.Windows.ThrowWithLastError()
+		End If
+	End Function
+
+	Override Function GetCharsCountCore(src As *Byte, srcCount As Long) As Long
+		GetCharsCountCore = MultiByteToWideChar(cp, 0, src As PCSTR, srcCount, 0, 0)
+		If srcCount <> 0 And GetCharsCountCore = 0 Then
+			ActiveBasic.Windows.ThrowWithLastError()
+		End If
+	End Function
+
+	Override Function GetCharsCore(src As *Byte, srcCount As Long, dst As *WCHAR, dstCount As Long) As Long
+		GetCharsCore = MultiByteToWideChar(cp, 0, src As PCSTR, srcCount, dst, dstCount)
+		If srcCount <> 0 And GetCharsCore = 0 Then
+			ActiveBasic.Windows.ThrowWithLastError()
+		End If
+	End Function
+
+	Override Function NextCharCore(s As *Byte, count As Long) As *Byte
+		NextCharCore = CharNextExA(cp As Word, s As PCSTR, 0) As *Byte
+	End Function
+
 Private
 	cp As DWord
 End Class
 
-Class WindowsCodePageEncoder
-	Inherits Encoder
-Public
-	Sub WindowsCodePageEncoder(codepage As DWord)
-		cp = codepage
-	End Sub
-
-	Override Sub Reset()
-		nextByte = 0
-	End Sub
-
-Protected
-	Override Sub ConvertCore(src As *WCHAR, srcCount As Long, dst As *Byte, dstCount As Long, flush As Boolean,
-		ByRef srcUsed As Long, ByRef dstUsed As Long, ByRef completed As Boolean)
-
-		Dim srcPos = 0 As Long
-		Dim dstPos = 0 As Long
-		If dstCount > 0 And nextByte <> 0 Then
-			dst[0] = nextByte
-			nextByte = 0
-			dstPos++
-		End If
-		While srcPos < srcCount And dstPos < srcCount
-			Dim buf[1] As CHAR
-			Dim len = WideCharToMultiByte(cp, WC_COMPOSITECHECK Or WC_DEFAULTCHAR, VarPtr(src[srcPos]), 1, buf, Len(buf), 0, 0)
-			If len = 0 Then
-				ActiveBasic.Windows.ThrowWithLastError()
-			End If
-			dst[dstPos] = buf[0] As Byte
-			If len = 2 Then
-				If dstCount = 1 Then
-					nextByte = buf[1] As Byte
-					Exit While
-				End If
-				dstPos++
-				dst[dstPos] = buf[1] As Byte
-				nextByte = 0
-			End If
-			srcPos++
-			dstPos++
-		Wend
-		srcUsed = srcPos
-		dstUsed = dstPos
-		completed = (srcPos = srcCount And dstPos = srcCount And nextByte = 0)
-	End Sub
-
-	Override Function GetBytesCountCore(src As *WCHAR, srcCount As Long, flush As Boolean) As Long
-		GetBytesCountCore = srcCount * 2 + 1 '暫定
-	End Function
-
-Private
-	cp As DWord
-	nextByte As Byte
-End Class
-
-Class WindowsCodePageDecoder
-	Inherits Decoder
-Public
-	Sub WindowsCodePageDecoder(codepage As DWord)
-		cp = codepage
-	End Sub
-
-Protected
-	Override Sub ConvertCore(src As *Byte, srcCount As Long, dst As *WCHAR, dstCount As Long, flush As Boolean,
-		ByRef srcUsed As Long, ByRef dstUsed As Long, ByRef completed As Boolean)
-
-		Dim srcPos = 0 As Long
-		Dim dstPos = 0 As Long
-		If dstCount > 0 And nextByte <> 0 Then
-			Dim buf[1] As CHAR
-			buf[0] = nextByte As CHAR
-			buf[1] = src[1] As CHAR
-			Dim len = MultiByteToWideChar(cp, 0, buf, Len(buf), VarPtr(dst[dstPos]), 10)
-			If len = 0 Then
-				ActiveBasic.Windows.ThrowWithLastError()
-			End If
-			srcPos++
-			dstPos++
-			nextByte = 0
-		End If
-		While srcPos < srcCount And dstPos < srcCount
-			Dim srcCharSize = 1 As Long
-			If IsDBCSLeadByteEx(cp, src[srcPos]) Then
-				srcCharSize = 2
-				If srcPos + 1 = srcCount Then
-					nextByte = src[srcPos]
-					Exit While
-				End If
-			End If
-			'将来的には行毎に変換しMB_USEGLYPHCHARSを使うようにしたい。
-			Dim len = MultiByteToWideChar(cp, 0, VarPtr(src[srcPos]) As *CHAR, srcCharSize, VarPtr(dst[dstPos]), 1)
-			If len = 0 Then
-				ActiveBasic.Windows.ThrowWithLastError()
-			End If
-			srcPos += srcCharSize
-			dstPos++
-		Wend
-		srcUsed = srcPos
-		dstUsed = dstPos
-		completed = (srcPos = srcCount And dstPos = srcCount And nextByte = 0)
-	End Sub
-
-	Override Function GetCharsCountCore(src As *Byte, srcCount As Long, flush As Boolean) As Long
-		GetCharsCountCore = srcCount + 1 '暫定
-	End Function
-
-Private
-	cp As DWord
-	nextByte As Byte
-End Class
-
 End Namespace
 
