Ignore:
Timestamp:
Feb 16, 2009, 4:26:24 PM (15 years ago)
Author:
イグトランス (egtra)
Message:

UTF8Encodingクラスをとりあえず使える状態に。ただし、BOM出力はまだ不可能。
(#231)

Location:
trunk/ab5.0/ablib/src/Classes/System/IO
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/ablib/src/Classes/System/IO/MemoryStream.ab

    r617 r682  
    339339    End Function*/
    340340
     341    Function ToPointer() As VoidPtr
     342        ToPointer = pointer
     343    End Function
     344
    341345    /*!
    342346    @brief  ストリームの内容全体をまるごと別のストリームに書き込みます。
  • trunk/ab5.0/ablib/src/Classes/System/IO/Stream.ab

    r609 r682  
    155155End Class
    156156
     157/*!
     158@brief 書き込みバイト数を記憶するヌルストリーム
     159Encoding関連で使用
     160@date 2009/02/16
     161@auther Egtra
     162*/
     163Class WriteCountingNullStream
     164    Inherits NullStream
     165Public
     166    Sub WriteCountingNullStream()
     167        writeCount = 0
     168    End Sub
     169
     170    Override Sub Write(buffer As *Byte, offset As Long, count As Long)
     171        If count < 0 Then
     172            Throw New ArgumentOutOfRangeException("count")
     173        End If
     174        writeCount += count
     175    End Sub
     176
     177    Override Sub WriteByte(b As Byte)
     178        writeCount++
     179    End Sub
     180
     181    /*!
     182    @brief 書き込まれたバイト数を返す。
     183    */
     184    Function WriteCount() As Long
     185        WriteCount = writeCount
     186    End Function
     187
     188Private
     189    writeCount As Long
     190End Class
     191
    157192End Namespace
    158193
  • trunk/ab5.0/ablib/src/Classes/System/IO/StreamWriter.ab

    r676 r682  
    2020    */
    2121    Sub StreamWriter(path As String)
    22         init(New FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None))
     22        init(New FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None), Nothing)
    2323    End Sub
    2424
     
    2828    */
    2929    Sub StreamWriter(stream As Stream)
    30         init(stream)
     30        init(stream, Nothing)
     31    End Sub
     32
     33    /*
     34    @date 2009/02/16
     35    @auther Egtra
     36    */
     37    Sub StreamWriter(stream As Stream, encoding As Text.Encoding)
     38        init(stream, encoding)
    3139    End Sub
    3240
     
    8391
    8492Private
    85     Sub init(stream As Stream)
     93    Sub init(stream As Stream, e As Text.Encoding)
    8694        s = stream
    8795        buf = New Text.StringBuilder(4096)
    88         '暫定。正式版ではUTF-8を標準とする。
    89         encoder = New Text.Detail.WindowsCodePageEncoder(CP_ACP)
     96        If ActiveBasic.IsNothing(e) Then
     97            '暫定。正式版ではUTF-8を標準とする。
     98            encoder = New Text.Detail.WindowsCodePageEncoder(CP_ACP)
     99        Else
     100            encoder = e.GetEncoder()
     101        End If
    90102    End Sub
    91103
Note: See TracChangeset for help on using the changeset viewer.