Changeset 682 for trunk/ab5.0/ablib/src/Classes/System/Text/Encoding.ab
- Timestamp:
- Feb 16, 2009, 4:26:24 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/ablib/src/Classes/System/Text/Encoding.ab
r676 r682 74 74 @date 2007/12/08 75 75 */ 76 Abstract Function GetBytesCountCore(src As *WCHAR, srcCount As Long) As Long 76 Virtual Function GetBytesCountCore(src As *WCHAR, srcCount As Long) As Long 77 Dim s = New IO.Detail.WriteCountingNullStream 78 GetEncoder().Encode(src, srcCount, s, True) 79 GetBytesCountCore = s.WriteCount 80 If GetBytesCountCore < 0 Then 81 Throw New OverflowException 82 End If 83 End Function 77 84 Public 78 85 /*! … … 110 117 @date 2007/12/08 111 118 */ 112 Abstract Function GetBytesCore(src As *WCHAR, srcCount As Long, dst As *Byte, dstCount As Long) As Long 119 Virtual Function GetBytesCore(src As *WCHAR, srcCount As Long, dst As *Byte, dstCount As Long) As Long 120 Dim s = New IO.MemoryStream 121 GetEncoder().Encode(src, srcCount, s, True) 122 Dim size = s.Position() 123 If size > (dstCount As QWord) Then 124 Throw New ArgumentException("dstCount") 125 End If 126 GetBytesCore = size As Long 127 memcpy(dst, s.ToPointer(), size As SIZE_T) 128 End Function 113 129 Public 114 130 /*! … … 136 152 @date 2007/12/08 137 153 */ 138 Abstract Function GetCharsCountCore(src As *Byte, srcCount As Long) As Long 154 Virtual Function GetCharsCountCore(src As *Byte, srcCount As Long) As Long 155 Dim s = New IO.MemoryStream(src, srcCount) 156 Dim l = New Collections.Generic.List<WCHAR> 157 GetDecoder().Decode(l, s) 158 GetCharsCountCore = l.Count 159 End Function 139 160 Public 140 161 /*! … … 172 193 @date 2007/12/08 173 194 */ 174 Abstract Function GetCharsCore(src As *Byte, srcCount As Long, dst As *WCHAR, dstCount As Long) As Long 195 Virtual Function GetCharsCore(src As *Byte, srcCount As Long, dst As *WCHAR, dstCount As Long) As Long 196 Dim s = New IO.MemoryStream(src, srcCount) 197 Dim l = New Collections.Generic.List<WCHAR> 198 GetDecoder().Decode(l, s) 199 If l.Count > dstCount Then 200 Throw New ArgumentException("dstCount") 201 End If 202 Dim p As *WCHAR 203 p = l 204 memcpy(dst, p, (l.Count As SIZE_T) * 2) 205 End Function 175 206 Public 176 207 #ifdef UNICODE
Note:
See TracChangeset
for help on using the changeset viewer.